Skip to content

Commit f91fed1

Browse files
authored
feat(player): Cursor fine-tuning (#2096)
1 parent 37b936b commit f91fed1

File tree

16 files changed

+764
-438
lines changed

16 files changed

+764
-438
lines changed

playground-template/control.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ function hideBackingTrack(at) {
129129

130130

131131
async function showBackingTrack(at) {
132+
if(!at.score.backingTrack) {
133+
hideBackingTrack();
134+
return;
135+
}
132136

133137
const audioElement = at.player.output.audioElement;
134138
if(audioElement !== backingTrackAudioElement) {

playground-template/youtube.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<head>
55
<meta charset="utf-8" />
6-
<title>AlphaTab Control Demo</title>
6+
<title>AlphaTab Youtube Sync</title>
77

88
<script src="/node_modules/@popperjs/core/dist/umd/popper.min.js"></script>
99
<script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

src.csharp/AlphaTab.Windows/DelegatedEventEmitter.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ public DelegatedEventEmitter(Action<Action> on, Action<Action> off)
1313
_off = off;
1414
}
1515

16-
public void On(Action value)
16+
public System.Action On(Action value)
1717
{
1818
_on(value);
19+
return () => _off(value);
1920
}
2021

2122
public void Off(Action value)
@@ -35,19 +36,21 @@ public DelegatedEventEmitter(Action<Action<T>> on, Action<Action<T>> off)
3536
_off = off;
3637
}
3738

38-
public void On(Action value)
39+
public System.Action On(Action value)
3940
{
4041
// not used internally
42+
return () => {};
4143
}
4244

4345
public void Off(Action value)
4446
{
4547
// not used internally
4648
}
4749

48-
public void On(Action<T> value)
50+
public System.Action On(Action<T> value)
4951
{
5052
_on(value);
53+
return () => _off(value);
5154
}
5255

5356
public void Off(Action<T> value)

src.csharp/AlphaTab/EventEmitter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace AlphaTab;
44

55
partial interface IEventEmitterOfT<T>
66
{
7-
void On(System.Action value);
7+
System.Action On(System.Action value);
88
void Off(System.Action value);
99
}
1010

@@ -14,14 +14,15 @@ partial class EventEmitterOfT<T>
1414
new System.Collections.Generic.Dictionary<System.Action, System.Action<T>>();
1515

1616
[Obsolete("Use event registration overload with parameter.", false)]
17-
public void On(System.Action value)
17+
public System.Action On(System.Action value)
1818
{
1919
var wrapper = new Action<T>(_=>
2020
{
2121
value();
2222
});
2323
_wrappers[value] = wrapper;
2424
On(wrapper);
25+
return () => Off(value);
2526
}
2627

2728
[Obsolete("Use event unregistration with parameter.", false)]

src.kotlin/alphaTab/android/src/main/java/alphaTab/platform/android/AndroidUiFacade.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ internal class AndroidUiFacade : IUiFacade<AlphaTabView> {
6363

6464
rootContainerBecameVisible = object : IEventEmitter,
6565
ViewTreeObserver.OnGlobalLayoutListener, View.OnLayoutChangeListener {
66-
override fun on(value: () -> Unit) {
66+
override fun on(value: () -> Unit): () -> Unit {
6767
if (rootContainer.isVisible) {
6868
value()
6969
} else {
7070
outerScroll.viewTreeObserver.addOnGlobalLayoutListener(this)
7171
outerScroll.addOnLayoutChangeListener(this)
7272
}
73+
return fun() { off(value) }
7374
}
7475

7576
override fun off(value: () -> Unit) {

0 commit comments

Comments
 (0)