implement 10sec skip action

This commit is contained in:
Adrian Ulrich 2015-05-25 11:04:22 +02:00
parent 109b1e727c
commit 4a534ce2e2
4 changed files with 33 additions and 2 deletions

View File

@ -279,6 +279,8 @@ THE SOFTWARE.
<string name="dequeue_rest">Dequeue rest</string>
<string name="queue">Queue</string>
<string name="toggle_controls">Toggle controls</string>
<string name="seek_10s_backward">Seek 10 seconds backward</string>
<string name="seek_10s_forward">Seek 10 seconds forward</string>
<string name="filebrowser_start">Filebrowser home</string>
<string name="customize_filebrowser_start">Filebrowser starts at this directory</string>

View File

@ -53,6 +53,8 @@ THE SOFTWARE.
<item>ClearQueue</item>
<item>ShowQueue</item>
<item>ToggleControls</item>
<item>SeekForward</item>
<item>SeekBackward</item>
</string-array>
<string-array name="swipe_action_entries">
<!-- This must match the order of swipe_action_values exactly -->
@ -71,6 +73,8 @@ THE SOFTWARE.
<item>@string/clear_queue</item>
<item>@string/show_queue</item>
<item>@string/toggle_controls</item>
<item>@string/seek_10s_forward</item>
<item>@string/seek_10s_backward</item>
</string-array>
<string-array name="default_playlist_action_entries">
<item>@string/play</item>

View File

@ -87,7 +87,15 @@ enum Action {
/**
* Toggle the controls in the playback activity.
*/
ToggleControls;
ToggleControls,
/**
* Seek 10 seconds forward
*/
SeekForward,
/**
* Seek 10 seconds back
*/
SeekBackward;
/**
* Retrieve an action from the given SharedPreferences.
@ -108,4 +116,4 @@ enum Action {
return def;
}
}
}
}

View File

@ -2114,6 +2114,23 @@ public final class PlaybackService extends Service
case ToggleControls:
// Handled in FullPlaybackActivity.performAction
break;
case SeekForward:
if (mCurrentSong != null) {
mPendingSeekSong = mCurrentSong.id;
mPendingSeek = getPosition() + 10000;
// We 'abuse' setCurrentSong as it will stop the playback and restart it
// at the new position, taking care of the ui update
setCurrentSong(0);
}
break;
case SeekBackward:
if (mCurrentSong != null) {
mPendingSeekSong = mCurrentSong.id;
mPendingSeek = getPosition() - 10000;
if (mPendingSeek < 1) mPendingSeek = 1; // must at least be 1
setCurrentSong(0);
}
break;
default:
throw new IllegalArgumentException("Invalid action: " + action);
}