From cba276055de0088cf683448fc6113ece050d4efc Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Wed, 30 Apr 2014 20:03:34 +0200 Subject: [PATCH] Add support for Chapters in player --- gpodder-core | 2 +- gpodder-ui-qml | 2 +- podcastparser | 2 +- qml/PlayerChaptersDialog.qml | 109 +++++++++++++++++++++++++++++++++++ qml/PlayerChaptersItem.qml | 35 +++++++++++ qml/PlayerPage.qml | 4 ++ 6 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 qml/PlayerChaptersDialog.qml create mode 100644 qml/PlayerChaptersItem.qml diff --git a/gpodder-core b/gpodder-core index 36ce31d..3f21e5c 160000 --- a/gpodder-core +++ b/gpodder-core @@ -1 +1 @@ -Subproject commit 36ce31d13ddcb6ba65b4ed38eaa4730df1a22df7 +Subproject commit 3f21e5c0913dd47d8c24242d7be8d8cd328ee923 diff --git a/gpodder-ui-qml b/gpodder-ui-qml index bb20181..c1d65e3 160000 --- a/gpodder-ui-qml +++ b/gpodder-ui-qml @@ -1 +1 @@ -Subproject commit bb20181a7727c3b4007eccb174613d53de0a5ad5 +Subproject commit c1d65e35725ca3e0e03d2ca4a143522d9ab4cd01 diff --git a/podcastparser b/podcastparser index 15b6e5a..378327c 160000 --- a/podcastparser +++ b/podcastparser @@ -1 +1 @@ -Subproject commit 15b6e5a75515f927a9b9020ba61f7a6e8f1cf821 +Subproject commit 378327cc793223326cb87bb8f8f1a9819225fa95 diff --git a/qml/PlayerChaptersDialog.qml b/qml/PlayerChaptersDialog.qml new file mode 100644 index 0000000..e4b310c --- /dev/null +++ b/qml/PlayerChaptersDialog.qml @@ -0,0 +1,109 @@ + +/** + * + * gPodder QML UI Reference Implementation + * Copyright (c) 2014, Thomas Perl + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +import 'common/util.js' as Util + +Page { + id: chapterSelector + + property var model + property var player + + SilicaListView { + anchors.fill: parent + + header: PageHeader { + title: 'Chapters' + } + + model: chapterSelector.model + + delegate: ListItem { + id: listItem + property bool inThePast: player.position > thisChapterStart && !currentItem + property real thisChapterStart: modelData.start * 1000 + property real nextChapterStart: { + if (index < chapterSelector.model.length - 1) { + return chapterSelector.model[index + 1].start * 1000; + } else { + return player.duration + 1; + } + } + property real chapterDuration: nextChapterStart - thisChapterStart + property real chapterProgress: (player.position - thisChapterStart) / chapterDuration + property bool currentItem: player.position >= modelData.start * 1000 && player.position < nextChapterStart + + highlighted: down || currentItem + + onClicked: { + chapterSelector.player.seekAndSync(modelData.start * 1000); + pageStack.pop(); + } + + Rectangle { + anchors { + bottom: parent.bottom + left: parent.left + } + + height: parent.height * 0.2 + width: parent.width * chapterProgress + + visible: listItem.currentItem + color: player.playing ? Theme.highlightColor : Theme.secondaryHighlightColor + opacity: .5 + } + + Label { + id: timeLabel + + anchors { + left: parent.left + verticalCenter: parent.verticalCenter + margins: Theme.paddingMedium + } + + color: listItem.highlighted ? Theme.highlightColor : Theme.secondaryColor + text: Util.formatDuration(modelData.start) + font.pixelSize: Theme.fontSizeSmall + } + + Label { + id: titleLabel + + anchors { + left: timeLabel.right + right: parent.right + verticalCenter: parent.verticalCenter + margins: Theme.paddingMedium + } + + color: listItem.highlighted ? Theme.highlightColor : (listItem.inThePast ? Theme.secondaryColor : Theme.primaryColor) + text: modelData.title + truncationMode: TruncationMode.Fade + } + } + + VerticalScrollDecorator { } + } +} diff --git a/qml/PlayerChaptersItem.qml b/qml/PlayerChaptersItem.qml new file mode 100644 index 0000000..63c537c --- /dev/null +++ b/qml/PlayerChaptersItem.qml @@ -0,0 +1,35 @@ + +/** + * + * gPodder QML UI Reference Implementation + * Copyright (c) 2014, Thomas Perl + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +import 'common' +import 'common/util.js' as Util + +MenuItem { + id: playerChaptersItem + + property var model + + visible: model.length > 0 + text: 'Chapters' + onClicked: pageStack.push('PlayerChaptersDialog.qml', { model: model, player: player }); +} diff --git a/qml/PlayerPage.qml b/qml/PlayerPage.qml index 4b7681c..0e29096 100644 --- a/qml/PlayerPage.qml +++ b/qml/PlayerPage.qml @@ -34,6 +34,10 @@ Page { contentHeight: column.height + column.spacing PullDownMenu { + PlayerChaptersItem { + model: player.episode_chapters + } + MenuItem { text: player.isPlaying ? 'Pause': 'Play' onClicked: {