ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #01674
[Merge] lp:~vthompson/music-app/fix-1445158 into lp:music-app
Victor Thompson has proposed merging lp:~vthompson/music-app/fix-1445158 into lp:music-app.
Commit message:
* Save position in currently playing song
Requested reviews:
Music App Developers (music-app-dev)
Related bugs:
Bug #1445158 in Ubuntu Music App: "Remember position of current audio file when app closes"
https://bugs.launchpad.net/music-app/+bug/1445158
For more details, see:
https://code.launchpad.net/~vthompson/music-app/fix-1445158/+merge/256741
* Save position in currently playing song
The Component.onDestruction signal won't work reliably to detect when to set a saved position--and at the moment it doesn't seem to work at all. However, a solution that would work perfectly while the app is not being suspended is to save the position when the position value changes (once a second). This solution will not be perfect when the app is able to be suspended, however, a few other things will need a similar solution including the queueIndex. I think we should and will be able to accommodate them both (queueIndex and the new savedPosition).
Currently when the source is loaded the duration is not detected, so the saved position can not be loaded/seeked to until the song is played.
--
Your team Music App Developers is requested to review the proposed merge of lp:~vthompson/music-app/fix-1445158 into lp:music-app.
=== modified file 'Player.qml'
--- Player.qml 2014-10-28 02:44:29 +0000
+++ Player.qml 2015-04-18 17:30:21 +0000
@@ -42,6 +42,7 @@
readonly property bool isPlaying: player.playbackState === MediaPlayer.PlayingState
readonly property var playbackState: mediaPlayerLoader.status == Loader.Ready ? mediaPlayerLoader.item.playbackState : MediaPlayer.StoppedState
property int position: 0
+ property bool positionLoaded: false
property alias repeat: settings.repeat
property alias shuffle: settings.shuffle
readonly property string source: mediaPlayerLoader.status == Loader.Ready ? mediaPlayerLoader.item.source : ""
@@ -140,6 +141,12 @@
function play() {
mediaPlayerLoader.item.play();
+ if (!positionLoaded) {
+ if (duration > savedPosition) {
+ mediaPlayerLoader.item.seek(savedPosition);
+ }
+ positionLoaded = true;
+ }
}
function playSong(filepath, index) {
@@ -187,7 +194,13 @@
muted: false
onDurationChanged: player.duration = duration
- onPositionChanged: player.position = position
+ onPositionChanged: {
+ if (positionLoaded) {
+ savedPosition = position
+ }
+ player.position = position
+ console.log("Position changed, updating saved pos: " + savedPosition)
+ }
onSourceChanged: {
// Force invalid source to ""
=== modified file 'music-app.qml'
--- music-app.qml 2015-04-03 23:49:13 +0000
+++ music-app.qml 2015-04-18 17:30:21 +0000
@@ -47,6 +47,7 @@
category: "StartupSettings"
property bool firstRun: true
+ property int savedPosition: 0 // Saved position in seconds
property int queueIndex: 0
property int tabIndex: -1
@@ -672,6 +673,7 @@
property bool toolbarShown: musicToolbar.visible
property bool selectedAlbum: false
property alias firstRun: startupSettings.firstRun
+ property alias savedPosition: startupSettings.savedPosition
property alias queueIndex: startupSettings.queueIndex
signal listItemSwiping(int i)
Follow ups