back button & media keys improvement
This commit is contained in:
parent
99425e65c3
commit
bb8e22cf93
3 changed files with 19 additions and 2 deletions
|
@ -183,7 +183,10 @@ export class wsapi {
|
|||
break;
|
||||
case "next":
|
||||
this._win.webContents.executeJavaScript(`if (MusicKit.getInstance().queue.nextPlayableItemIndex != -1 && MusicKit.getInstance().queue.nextPlayableItemIndex != null) {
|
||||
MusicKit.getInstance().changeToMediaAtIndex(MusicKit.getInstance().queue.nextPlayableItemIndex);}`);
|
||||
try {
|
||||
app.prevButtonBackIndicator = false;
|
||||
} catch (e) { }
|
||||
MusicKit.getInstance().changeToMediaAtIndex(MusicKit.getInstance().queue.nextPlayableItemIndex);}`);
|
||||
response.message = "Next";
|
||||
break;
|
||||
case "previous":
|
||||
|
|
|
@ -136,6 +136,9 @@ const MusicKitInterop = {
|
|||
},
|
||||
|
||||
next: () => {
|
||||
try {
|
||||
app.prevButtonBackIndicator = false;
|
||||
} catch (e) { }
|
||||
if (MusicKit.getInstance().queue.nextPlayableItemIndex != -1 && MusicKit.getInstance().queue.nextPlayableItemIndex != null)
|
||||
MusicKit.getInstance().changeToMediaAtIndex(MusicKit.getInstance().queue.nextPlayableItemIndex);
|
||||
// MusicKit.getInstance().skipToNextItem().then(r => console.log(`[MusicKitInterop.next] Skipping to Next ${r}`));
|
||||
|
|
|
@ -250,7 +250,8 @@ const app = new Vue({
|
|||
items: {},
|
||||
headerItems: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
pauseButtonTimer : null
|
||||
},
|
||||
watch: {
|
||||
cfg: {
|
||||
|
@ -813,6 +814,8 @@ const app = new Vue({
|
|||
this.page = "home"
|
||||
}
|
||||
|
||||
this.mediaKeyFixes()
|
||||
|
||||
setTimeout(() => {
|
||||
this.getSocialBadges()
|
||||
this.getBrowsePage();
|
||||
|
@ -1355,8 +1358,11 @@ const app = new Vue({
|
|||
prevButton() {
|
||||
if (!app.prevButtonBackIndicator && app.mk.nowPlayingItem && app.mk.currentPlaybackTime > 2) {
|
||||
app.prevButtonBackIndicator = true;
|
||||
try{clearTimeout(app.pauseButtonTimer)} catch (e){ }
|
||||
app.mk.seekToTime(0);
|
||||
app.pauseButtonTimer = setTimeout(app.prevButtonBackIndicator = false,3000);
|
||||
} else {
|
||||
try{clearTimeout(app.pauseButtonTimer)} catch (e){ }
|
||||
app.prevButtonBackIndicator = false;
|
||||
app.skipToPreviousItem()
|
||||
}
|
||||
|
@ -3743,6 +3749,7 @@ const app = new Vue({
|
|||
}
|
||||
},
|
||||
skipToNextItem(){
|
||||
app.prevButtonBackIndicator = false;
|
||||
// app.mk.skipToNextItem() is buggy somehow so use this
|
||||
if (this.mk.queue.nextPlayableItemIndex != -1 && this.mk.queue.nextPlayableItemIndex != null)
|
||||
this.mk.changeToMediaAtIndex(this.mk.queue.nextPlayableItemIndex);
|
||||
|
@ -3751,6 +3758,10 @@ const app = new Vue({
|
|||
// app.mk.skipToPreviousItem() is buggy somehow so use this
|
||||
if (this.mk.queue.previousPlayableItemIndex != -1 && this.mk.queue.previousPlayableItemIndex != null)
|
||||
this.mk.changeToMediaAtIndex(this.mk.queue.previousPlayableItemIndex);
|
||||
},
|
||||
mediaKeyFixes(){
|
||||
navigator.mediaSession.setActionHandler('previoustrack', function() { app.prevButton() });
|
||||
navigator.mediaSession.setActionHandler('nexttrack', function() { app.skipToNextItem() });
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue