Added resume from history
This commit is contained in:
parent
913532fcdb
commit
02ba9a7c42
3 changed files with 354 additions and 304 deletions
|
@ -12,7 +12,8 @@ export class Store {
|
|||
"discord_rpc_clear_on_pause": true,
|
||||
"language": "en_US", // electron.app.getLocale().replace('-', '_') this can be used in future
|
||||
"playbackNotifications": true,
|
||||
"update_branch": "innolab"
|
||||
"update_branch": "main",
|
||||
"resumeOnStartupBehavior": "local"
|
||||
},
|
||||
"home": {
|
||||
"followedArtists": [],
|
||||
|
|
|
@ -347,7 +347,8 @@ const app = new Vue({
|
|||
} else {
|
||||
// fallback English plural forms ( old i18n )
|
||||
if (options["count"] > 1) {
|
||||
return this.lz[message+ "s"] ?? this.lz[message]} else { return this.lz[message] ?? this.lz[message+ "s"]}
|
||||
return this.lz[message + "s"] ?? this.lz[message]
|
||||
} else { return this.lz[message] ?? this.lz[message + "s"] }
|
||||
}
|
||||
} else if (typeof this.lz[message] === "object") {
|
||||
return (this.lz[message])[Object.keys(this.lz[message])[0]]
|
||||
|
@ -664,6 +665,9 @@ const app = new Vue({
|
|||
app.cfg.audio.quality = "HIGH"
|
||||
}
|
||||
|
||||
switch (this.cfg.general.resumeOnStartupBehavior) {
|
||||
default:
|
||||
case "local":
|
||||
// load last played track
|
||||
try {
|
||||
let lastItem = window.localStorage.getItem("currentTrack")
|
||||
|
@ -714,6 +718,32 @@ const app = new Vue({
|
|||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
break;
|
||||
case "history":
|
||||
let history = await app.mk.api.v3.music(`/v1/me/recent/played/tracks`, { l : app.mklang})
|
||||
if (history.data.data.length > 0) {
|
||||
let lastItem = history.data.data[0]
|
||||
let kind = lastItem.attributes.playParams.kind;
|
||||
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
app.mk.setQueue({
|
||||
[truekind]: [lastItem.attributes.playParams.id],
|
||||
parameters: { l: app.mklang }
|
||||
})
|
||||
app.mk.mute()
|
||||
setTimeout(() => {
|
||||
app.mk.play().then(() => {
|
||||
app.mk.pause().then(() => {
|
||||
app.mk.unmute()
|
||||
})
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
break;
|
||||
case "disabled":
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
|
||||
|
||||
|
@ -2884,7 +2914,8 @@ const app = new Vue({
|
|||
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.attributes.playParams.id ?? item.id))
|
||||
}
|
||||
}
|
||||
)} else {
|
||||
)
|
||||
} else {
|
||||
app.mk.setQueue({ [kind + "s"]: itemsToPlay[kind] }).then(function () {
|
||||
ind += 1;
|
||||
console.log(ind, Object.keys(itemsToPlay).length)
|
||||
|
@ -2892,7 +2923,8 @@ const app = new Vue({
|
|||
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.attributes.playParams.id ?? item.id))
|
||||
}
|
||||
}
|
||||
)}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,23 @@
|
|||
<input type="checkbox" v-model="app.mk.privateEnabled" switch/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-option-line">
|
||||
<div class="md-option-segment">
|
||||
Resume behavior<br>
|
||||
<small>
|
||||
Resume behavior affects how Cider will resume your session when you return to the app.<br>
|
||||
<b>Locally: </b> Cider will resume your last session on this machine.<br>
|
||||
<b>History: </b> Cider will queue the last song from your overall Apple Music history, across devices.
|
||||
</small>
|
||||
</div>
|
||||
<div class="md-option-segment md-option-segment_auto">
|
||||
<select class="md-select" style="width:180px;" v-model="$root.cfg.general.resumeOnStartupBehavior">
|
||||
<option value="disabled">Disabled</option>
|
||||
<option value="local">Locally</option>
|
||||
<option value="history">History</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-option-header">
|
||||
<span>{{$root.getLz('settings.header.audio')}}</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue