From 19b32961720cd5b8116a060019888eb7bfcf3855 Mon Sep 17 00:00:00 2001 From: Grigorii Zimin Date: Fri, 3 Apr 2020 18:51:33 +0000 Subject: Revert "Remove videoplayer as it doesn't work in Neptune UI 5.14" This reverts commit 7a467588143cacbbf14c3e01c1383734f8fd8f25. Reason for revert: works...but video folder should contains files and opengl there is opengl problem Change-Id: Ie5631bf75ad1ac1ffcbfcd64b877f5a2a5f1b639 Reviewed-by: Grigorii Zimin --- com.luxoft.videoplayer/ControlsOverlay.qml | 173 ++++++++++++++++++++++ com.luxoft.videoplayer/Main.qml | 62 ++++++++ com.luxoft.videoplayer/OpenFilesPanel.qml | 67 +++++++++ com.luxoft.videoplayer/VideoPlayerPanel.qml | 99 +++++++++++++ com.luxoft.videoplayer/VideoPlayerView.qml | 63 ++++++++ com.luxoft.videoplayer/com.luxoft.videoplayer.pro | 19 +++ com.luxoft.videoplayer/icon.png | Bin 0 -> 1034 bytes com.luxoft.videoplayer/info.yaml | 12 ++ com.luxoft.videoplayer/utils.js | 92 ++++++++++++ qt-auto-extra-apps.pro | 1 + 10 files changed, 588 insertions(+) create mode 100644 com.luxoft.videoplayer/ControlsOverlay.qml create mode 100644 com.luxoft.videoplayer/Main.qml create mode 100644 com.luxoft.videoplayer/OpenFilesPanel.qml create mode 100644 com.luxoft.videoplayer/VideoPlayerPanel.qml create mode 100644 com.luxoft.videoplayer/VideoPlayerView.qml create mode 100644 com.luxoft.videoplayer/com.luxoft.videoplayer.pro create mode 100644 com.luxoft.videoplayer/icon.png create mode 100644 com.luxoft.videoplayer/info.yaml create mode 100644 com.luxoft.videoplayer/utils.js diff --git a/com.luxoft.videoplayer/ControlsOverlay.qml b/com.luxoft.videoplayer/ControlsOverlay.qml new file mode 100644 index 0000000..96947ca --- /dev/null +++ b/com.luxoft.videoplayer/ControlsOverlay.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.3 +import QtMultimedia 5.12 + +import shared.Sizes 1.0 + +import "utils.js" as Utils + +Rectangle { + id: root + color: Qt.rgba(0, 0, 0, .6) + + readonly property bool playingOrPaused: player.playbackState === MediaPlayer.PausedState + || player.playbackState === MediaPlayer.PlayingState + + property bool shouldShow: false + property Video player + + function openFilesPanel() { + filesPanel.visible = true; + } + + signal fileOpenRequested(url fileURL) + + Timer { + id: hideTimer + interval: 2500 + running: root.shouldShow && !filesPanel.visible + repeat: true + onTriggered: { + if (player.hasVideo) { + root.shouldShow = false; + } + } + } + + RowLayout { + id: labelsLayout + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: Sizes.dp(24) + + ToolButton { + text: qsTr("Open...") + onClicked: filesPanel.visible = !filesPanel.visible + } + + Label { + Layout.alignment: Qt.AlignHCenter + horizontalAlignment: Text.AlignHCenter + visible: player.hasVideo + Layout.preferredWidth: root.width/3*2 + elide: Label.ElideMiddle + text: Utils.baseName(player.source) + } + + Label { + visible: player.hasVideo + text: "(%1)".arg(Utils.playbackStateToString(player.playbackState)) + (player.muted ? " " + qsTr("Muted") : "") + } + } + + OpenFilesPanel { + id: filesPanel + anchors.left: parent.left + anchors.right: parent.right + anchors.top: labelsLayout.bottom + anchors.bottom: playbackControls.top + anchors.margins: Sizes.dp(24) + visible: false + onFileOpenRequested: root.fileOpenRequested(fileURL) + } + + RowLayout { + id: playbackControls + visible: player.hasVideo + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: visible ? implicitHeight : 0 + anchors.margins: Sizes.dp(24) + spacing: Sizes.dp(24) + + Label { + text: Utils.msToTime(posSlider.value) + } + + Slider { + id: posSlider + Layout.fillWidth: true + from: 0 + to: player.duration + value: player.position + enabled: player.seekable + onMoved: { + hideTimer.restart(); + player.seek(value); + } + } + + Label { + text: Utils.msToTime(player.duration) + } + + ToolButton { + id: playPauseButton + Layout.preferredWidth: Sizes.dp(64) + Layout.preferredHeight: Sizes.dp(64) + icon.name: player.playbackState == MediaPlayer.PlayingState ? "ic-pause" : "ic_play" + enabled: player.hasVideo + onClicked: { + hideTimer.restart(); + player.playbackState == MediaPlayer.PlayingState ? player.pause() : player.play(); + } + } + ToolButton { + id: stopButton + Layout.preferredWidth: Sizes.dp(64) + Layout.preferredHeight: Sizes.dp(64) + icon.name: "ic-close" // FIXME probably not the best icon :/ + enabled: root.playingOrPaused + onClicked: { + hideTimer.restart(); + player.stop(); + } + } + ToolButton { + id: muteButton + Layout.preferredWidth: Sizes.dp(64) + Layout.preferredHeight: Sizes.dp(64) + icon.name: checked ? "ic-volume-0" : "ic-volume-2" + enabled: root.playingOrPaused + checkable: true + checked: player.muted + onToggled: { + hideTimer.restart(); + player.muted = !player.muted; + } + } + } +} diff --git a/com.luxoft.videoplayer/Main.qml b/com.luxoft.videoplayer/Main.qml new file mode 100644 index 0000000..d44ef3e --- /dev/null +++ b/com.luxoft.videoplayer/Main.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import application.windows 1.0 +import shared.utils 1.0 + +import "." + +ApplicationCCWindow { + id: root + + MultiPointTouchArea { + anchors.fill: parent + anchors.margins: 30 + touchPoints: [ TouchPoint { id: touchPoint1 } ] + + property int count: 0 + onReleased: { + count += 1; + root.setWindowProperty("activationCount", count); + } + } + + VideoPlayerView { + x: root.exposedRect.x + y: root.exposedRect.y + width: root.exposedRect.width + height: root.exposedRect.height + + state: root.neptuneState + bottomWidgetHide: root.exposedRect.height === root.targetHeight + } +} diff --git a/com.luxoft.videoplayer/OpenFilesPanel.qml b/com.luxoft.videoplayer/OpenFilesPanel.qml new file mode 100644 index 0000000..0a2d184 --- /dev/null +++ b/com.luxoft.videoplayer/OpenFilesPanel.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import Qt.labs.folderlistmodel 2.11 +import Qt.labs.platform 1.0 + +Item { + id: root + + signal fileOpenRequested(url fileURL) + + FolderListModel { + id: folderListModel + nameFilters: ["*"] + showDirs: false + showDotAndDotDot: false + folder: StandardPaths.standardLocations(StandardPaths.MoviesLocation)[0] + } + + ListView { + anchors.fill: parent + model: folderListModel + delegate: ItemDelegate { + text: model.fileName + contentItem: Label { + rightPadding: parent.spacing + text: parent.text + elide: Text.ElideMiddle + verticalAlignment: Text.AlignVCenter + } + onClicked: { + root.fileOpenRequested(model.fileURL); + root.visible = false; + } + } + } +} diff --git a/com.luxoft.videoplayer/VideoPlayerPanel.qml b/com.luxoft.videoplayer/VideoPlayerPanel.qml new file mode 100644 index 0000000..71be88f --- /dev/null +++ b/com.luxoft.videoplayer/VideoPlayerPanel.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtMultimedia 5.12 + +import "utils.js" as Utils + +Rectangle { + implicitWidth: 800 + implicitHeight: 600 + color: "black" + + Video { + id: videoplayer + anchors.fill: parent + audioRole: MediaPlayer.VideoRole + autoPlay: true + + onStatusChanged: { + console.debug("Video player status changed:", Utils.statusToString(status)) + } + onErrorChanged: { + console.warn("Video player error: %1\n%2".arg(error).arg(errorString)) + } + onPlaybackStateChanged: { + console.debug("Video playback state changed:", Utils.playbackStateToString(playbackState)) + } + onVolumeChanged: { + console.debug("Video player volume changed:", volume) + } + Component.onCompleted: { + console.debug("Video player availability:", Utils.availabilityToString(availability)) + console.debug("Supported audio roles:", supportedAudioRoles()) + } + + focus: true + Keys.onLeftPressed: seek(position - 5000) + Keys.onRightPressed: seek(position + 5000) + Keys.onUpPressed: videoplayer.volume += .1 + Keys.onDownPressed: videoplayer.volume -= .1 + Keys.enabled: videoplayer.seekable + + MouseArea { + anchors.fill: parent + onClicked: controls.shouldShow = !controls.shouldShow + } + + ToolButton { + anchors.centerIn: parent + visible: !videoplayer.hasVideo && !controls.shouldShow + text: qsTr("Open video...") + onClicked: { + controls.shouldShow = !controls.shouldShow; + controls.openFilesPanel(); + } + } + + ControlsOverlay { + id: controls + width: parent.width + height: parent.height + x: parent.x + y: shouldShow ? 0 : parent.height + player: videoplayer + Behavior on y { NumberAnimation {}} + onFileOpenRequested: videoplayer.source = fileURL + } + } +} diff --git a/com.luxoft.videoplayer/VideoPlayerView.qml b/com.luxoft.videoplayer/VideoPlayerView.qml new file mode 100644 index 0000000..50c5050 --- /dev/null +++ b/com.luxoft.videoplayer/VideoPlayerView.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.3 + +import shared.animations 1.0 +import shared.controls 1.0 +import shared.utils 1.0 +import shared.Style 1.0 +import shared.Sizes 1.0 + +Item { + id: root + + property bool bottomWidgetHide: false + + // Top content background + Image { + id: topContentBg + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + height: Sizes.dp(436) + source: Style.image("app-fullscreen-top-bg") + visible: root.state === "Maximized" + } + + ColumnLayout { + anchors.fill: parent + VideoPlayerPanel { + anchors.fill: parent + } + } +} diff --git a/com.luxoft.videoplayer/com.luxoft.videoplayer.pro b/com.luxoft.videoplayer/com.luxoft.videoplayer.pro new file mode 100644 index 0000000..f0c6bb3 --- /dev/null +++ b/com.luxoft.videoplayer/com.luxoft.videoplayer.pro @@ -0,0 +1,19 @@ +TEMPLATE = aux + +FILES += info.yaml \ + icon.png \ + Main.qml \ + VideoPlayerView.qml \ + VideoPlayerPanel.qml \ + ControlsOverlay.qml \ + OpenFilesPanel.qml \ + utils.js + +app.files = $$FILES +app.path = /apps/com.luxoft.videoplayer +INSTALLS += app + +AM_MANIFEST = info.yaml +AM_PACKAGE_DIR = $$app.path + +load(am-app) diff --git a/com.luxoft.videoplayer/icon.png b/com.luxoft.videoplayer/icon.png new file mode 100644 index 0000000..2734956 Binary files /dev/null and b/com.luxoft.videoplayer/icon.png differ diff --git a/com.luxoft.videoplayer/info.yaml b/com.luxoft.videoplayer/info.yaml new file mode 100644 index 0000000..4d22d92 --- /dev/null +++ b/com.luxoft.videoplayer/info.yaml @@ -0,0 +1,12 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'com.luxoft.videoplayer' +icon: 'icon.png' +code: 'Main.qml' +runtime: 'qml' +name: + en: 'Video Player' + +categories: [ 'other', 'widget' ] +mimeTypes: [ 'x-scheme-handler/x-videoplayer' ] diff --git a/com.luxoft.videoplayer/utils.js b/com.luxoft.videoplayer/utils.js new file mode 100644 index 0000000..82e8988 --- /dev/null +++ b/com.luxoft.videoplayer/utils.js @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +.pragma library + +.import QtMultimedia 5.12 as QtMultimedia + +function baseName(str) +{ + var base = String(str).substring(String(str).lastIndexOf('/') + 1); + return base; +} + +function availabilityToString(availability) { + switch (availability) { + case QtMultimedia.MediaPlayer.Available: + return "Available"; + case QtMultimedia.MediaPlayer.Busy: + return "Busy"; + case QtMultimedia.MediaPlayer.Unavailable: + return "Unavailable"; + case QtMultimedia.MediaPlayer.ResourceMissing: + return "Missing resource"; + default: + return "Unknown status: %1".arg(availability); + } +} + +function statusToString(status) { + switch (status) { + case QtMultimedia.MediaPlayer.NoMedia: return "No media"; + case QtMultimedia.MediaPlayer.Loading: return "Loading"; + case QtMultimedia.MediaPlayer.Loaded: return "Loaded"; + case QtMultimedia.MediaPlayer.Buffering: return "Buffering"; + case QtMultimedia.MediaPlayer.Stalled: return "Stalled"; + case QtMultimedia.MediaPlayer.Buffered: return "Buffered"; + case QtMultimedia.MediaPlayer.EndOfMedia: return "End of media"; + case QtMultimedia.MediaPlayer.InvalidMedia: return "Invalid media"; + case QtMultimedia.MediaPlayer.UnknownStatus: + default: + return "Unknown status %1".arg(status); + } +} + +function playbackStateToString(playbackState) { + switch (playbackState) { + case QtMultimedia.MediaPlayer.PlayingState: return qsTr("Playing"); + case QtMultimedia.MediaPlayer.PausedState: return qsTr("Paused"); + case QtMultimedia.MediaPlayer.StoppedState: return qsTr("Stopped"); + default: return qsTr("Unknown playback state %1").arg(playbackState); + } +} + +function msToTime(duration) { + var seconds = Math.floor((duration / 1000) % 60); + var minutes = Math.floor((duration / (1000 * 60)) % 60); + var hours = Math.floor((duration / (1000 * 60 * 60)) % 24); + + hours = (hours < 10) ? "0" + hours : hours; + minutes = (minutes < 10) ? "0" + minutes : minutes; + seconds = (seconds < 10) ? "0" + seconds : seconds; + + return hours + ":" + minutes + ":" + seconds; +} diff --git a/qt-auto-extra-apps.pro b/qt-auto-extra-apps.pro index f1d982f..a4d519a 100644 --- a/qt-auto-extra-apps.pro +++ b/qt-auto-extra-apps.pro @@ -2,6 +2,7 @@ TEMPLATE = subdirs SUBDIRS = com.pelagicore.camera \ com.pelagicore.youtube \ com.luxoft.webbrowser \ + com.luxoft.videoplayer \ com.luxoft.greenomics \ com.pelagicore.samegame \ com.pelagicore.webradio \ -- cgit v1.2.3