Add keyboard navigation for media playback

This commit is contained in:
Thomas Perl 2014-10-28 11:37:26 +01:00
parent 76d1d48bff
commit cb4aa06901
3 changed files with 48 additions and 1 deletions

View file

@ -40,6 +40,14 @@ MediaPlayer {
property int lastDuration: 0
property int playedFrom: 0
function togglePause() {
if (playbackState === MediaPlayer.PlayingState) {
pause();
} else if (playbackState === MediaPlayer.PausedState) {
play();
}
}
function playbackEpisode(episode_id) {
if (episode == episode_id) {
// If the episode is already loaded, just start playing

View file

@ -34,6 +34,35 @@ Item {
GPodderPodcastListModel { id: podcastListModel }
GPodderPodcastListModelConnections {}
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Space:
player.togglePause();
break;
case Qt.Key_Q:
player.seekAndSync(player.position - 60 * 1000);
break;
case Qt.Key_W:
player.seekAndSync(player.position - 10 * 1000);
break;
case Qt.Key_O:
player.seekAndSync(player.position + 10 * 1000);
break;
case Qt.Key_P:
player.seekAndSync(player.position + 60 * 1000);
break;
case Qt.Key_Escape:
case Qt.Key_Backspace:
backButton.clicked();
break;
default:
break;
}
}
// Initial focus
focus: true
property real scalef: (width < height) ? (width / 480) : (height / 480)
property int shorterSide: (width < height) ? width : height
property int dialogsVisible: 0
@ -169,7 +198,11 @@ Item {
icon: Icons.arrow_left
enabled: pgst.hasBackButton
onClicked: pgst.children[pgst.children.length-1].closePage();
onClicked: {
if (enabled) {
pgst.children[pgst.children.length-1].closePage();
}
}
}
}

View file

@ -38,6 +38,12 @@ Item {
TextInput {
id: textInput
Component.onDestruction: {
// Return keyboard focus to pgst
pgst.focus = true;
}
anchors {
verticalCenter: parent.verticalCenter
left: parent.left