diff options
Diffstat (limited to 'basicsuite/qt5-everywhere/demos/video')
27 files changed, 1466 insertions, 0 deletions
diff --git a/basicsuite/qt5-everywhere/demos/video/Content.qml b/basicsuite/qt5-everywhere/demos/video/Content.qml new file mode 100644 index 0000000..de25f13 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/Content.qml @@ -0,0 +1,67 @@ + /**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtMultimedia 5.0 + +Rectangle { + id: root + property alias videoPlayer: videoContent + + color: "black" + + ContentVideo { + id: videoContent + anchors.fill: root + visible: mediaSource == "" ? false : true + } + + function openVideo(path) { + stop(); + videoContent.mediaSource = path + } + + function stop() { + if (videoContent.mediaSource !== undefined) { + videoContent.stop(); + } + } +} diff --git a/basicsuite/qt5-everywhere/demos/video/ContentVideo.qml b/basicsuite/qt5-everywhere/demos/video/ContentVideo.qml new file mode 100644 index 0000000..83c9ab7 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/ContentVideo.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtMultimedia 5.0 + +VideoOutput { + id: videoOutput + source: mediaPlayer + fillMode: VideoOutput.PreserveAspectFit + property alias mediaSource: mediaPlayer.source + property alias mediaPlayer: mediaPlayer + property bool isPlaying: false + + MediaPlayer { + id: mediaPlayer + autoLoad: true + autoPlay: true + + onPlaybackStateChanged: { + if (playbackState === MediaPlayer.PlayingState) + videoOutput.isPlaying = true; + else + videoOutput.isPlaying = false; + } + + Component.onDestruction: { + mediaPlayer.stop() + } + } + function play() { mediaPlayer.play() } + function stop() { mediaPlayer.stop() } +} diff --git a/basicsuite/qt5-everywhere/demos/video/ControlBar.qml b/basicsuite/qt5-everywhere/demos/video/ControlBar.qml new file mode 100644 index 0000000..f013dcf --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/ControlBar.qml @@ -0,0 +1,290 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtMultimedia 5.0 + +Item { + id: controlBar + anchors.fill: parent + + property MediaPlayer mediaPlayer: null + property bool isMouseAbove: false + property int margin: applicationWindow.width * 0.01 + + signal openURL() + + state: "VISIBLE" + + onMediaPlayerChanged: { + if (mediaPlayer === null) + return; + volumeControl.volume = mediaPlayer.volume; + } + + function updateStatusText() + { + var strText = "" + switch (mediaPlayer.status) { + case MediaPlayer.NoMedia: strText = "No Media"; break; + case MediaPlayer.Loading: strText = "Loading..."; break; + case MediaPlayer.Buffering: strText = "Buffering..."; break; + case MediaPlayer.Stalled: strText = "Stalled"; break; + case MediaPlayer.EndOfMedia: strText = "EndOfMedia"; break; + case MediaPlayer.InvalidMedia: strText = "InvalidMedia"; break; + case MediaPlayer.UnknownStatus: strText = "UnknownStatus"; break; + default: strText = ""; break; + } + + statusText.text = strText; + } + + Rectangle { + anchors.right: parent.right + anchors.top: parent.top + width: applicationWindow.height * 0.12 + height: width + color: "#88333333" + + Image { + id: closeImage + source: "images/CloseButton.png" + anchors.centerIn: parent + width: 0.5*parent.height + height: width + opacity: closeMouseArea.pressed ? 0.6 : 1 + smooth: true + } + + MouseArea { + id: closeMouseArea + anchors.fill: parent + onClicked: { + if (mediaPlayer !== null) { + mediaPlayer.stop(); + mediaPlayer.source = ""; + } + + videoSelector.show(); + } + } + } + + Rectangle { + id: bottomBar + height: parent.height * 0.2 + color: "#88333333" + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.right: parent.right + + property double playBackHeight: height*0.48 + property double seekHeight: height*0.48 + + VolumeControl { + id: volumeControl + anchors.verticalCenter: playbackControl.verticalCenter + anchors.left: bottomBar.left + anchors.leftMargin: bottomBar.margin + height: bottomBar.playBackHeight + width: parent.width * 0.3 + onVolumeChanged: { + if (mediaPlayer !== null) + mediaPlayer.volume = volume + } + + Connections { + target: mediaPlayer + onVolumeChanged: volumeControl.volume = mediaPlayer.volume + } + } + + //Playback Controls + PlaybackControl { + id: playbackControl + anchors.horizontalCenter: bottomBar.horizontalCenter + anchors.top: bottomBar.top + anchors.topMargin: bottomBar.margin + height: bottomBar.playBackHeight + + onPlayButtonPressed: { + if (mediaPlayer === null) + return; + + if (isPlaying) { + mediaPlayer.pause(); + } else { + mediaPlayer.play(); + } + } + } + + Text { + id: statusText + anchors.right: parent.right + anchors.verticalCenter: playbackControl.verticalCenter + anchors.rightMargin: bottomBar.margin + verticalAlignment: Text.AlignVCenter + height: bottomBar.playBackHeight + font.pixelSize: playbackControl.height * 0.5 + color: "white" + } + + //Seek controls + SeekControl { + id: seekControl + anchors.bottom: bottomBar.bottom + anchors.right: bottomBar.right + anchors.left: bottomBar.left + height: bottomBar.seekHeight + anchors.leftMargin: bottomBar.margin + anchors.rightMargin: bottomBar.margin + + enabled: playbackControl.isPlaybackEnabled + duration: mediaPlayer !== null ? mediaPlayer.duration : 0 + + onSeekValueChanged: { + if (mediaPlayer !== null) { + mediaPlayer.seek(newPosition); + position = mediaPlayer.position; + } + } + + Component.onCompleted: { + if (mediaPlayer !== null) + seekable = mediaPlayer.seekable; + } + } + + Connections { + target: mediaPlayer + onPositionChanged: { + if (!seekControl.pressed) seekControl.position = mediaPlayer.position; + } + onStatusChanged: { + if ((mediaPlayer.status == MediaPlayer.Loaded) || (mediaPlayer.status == MediaPlayer.Buffered) || mediaPlayer.status === MediaPlayer.Buffering || mediaPlayer.status === MediaPlayer.EndOfMedia) + playbackControl.isPlaybackEnabled = true; + else + playbackControl.isPlaybackEnabled = false; + updateStatusText(); + } + onErrorChanged: { + updateStatusText(); + } + + onPlaybackStateChanged: { + if (mediaPlayer.playbackState === MediaPlayer.PlayingState) { + playbackControl.isPlaying = true; + applicationWindow.resetTimer(); + } else { + show(); + playbackControl.isPlaying = false; + } + } + + onSeekableChanged: { + seekControl.seekable = mediaPlayer.seekable; + } + } + } + + //Usage: give the value you wish to modify position, + //returns a value between 0 and duration + function normalizeSeek(value) { + var newPosition = mediaPlayer.position + value; + if (newPosition < 0) + newPosition = 0; + else if (newPosition > mediaPlayer.duration) + newPosition = mediaPlayer.duration; + return newPosition; + } + + function hide() { + controlBar.state = "HIDDEN"; + } + + function show() { + controlBar.state = "VISIBLE"; + } + + states: [ + State { + name: "HIDDEN" + PropertyChanges { + target: controlBar + opacity: 0.0 + } + }, + State { + name: "VISIBLE" + PropertyChanges { + target: controlBar + opacity: 0.95 + } + } + ] + + transitions: [ + Transition { + from: "HIDDEN" + to: "VISIBLE" + NumberAnimation { + id: showAnimation + target: controlBar + properties: "opacity" + from: 0.0 + to: 1.0 + duration: 200 + } + }, + Transition { + from: "VISIBLE" + to: "HIDDEN" + NumberAnimation { + id: hideAnimation + target: controlBar + properties: "opacity" + from: 0.95 + to: 0.0 + duration: 200 + } + } + ] +} diff --git a/basicsuite/qt5-everywhere/demos/video/ImageButton.qml b/basicsuite/qt5-everywhere/demos/video/ImageButton.qml new file mode 100644 index 0000000..428f6de --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/ImageButton.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + height: parent.height * 0.8 + width: image.width * image.scale + + property alias enabled: mouseArea.enabled + property alias imageSource: image.source + + property bool checkable: false + property bool checked: false + property alias hover: mouseArea.containsMouse + property alias pressed: mouseArea.pressed + property double imageSize: 0.9*root.height + + opacity: enabled ? 1.0 : 0.3 + signal clicked + + Image { + id: image + anchors.centerIn: parent + scale: root.height / height + visible: true + opacity: pressed ? 0.6 : 1 + smooth: true + } + + MouseArea { + id: mouseArea + hoverEnabled: true + anchors.fill: root + onPositionChanged: applicationWindow.resetTimer() + onClicked: root.clicked(); + } +} diff --git a/basicsuite/qt5-everywhere/demos/video/PlaybackControl.qml b/basicsuite/qt5-everywhere/demos/video/PlaybackControl.qml new file mode 100644 index 0000000..2d7307e --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/PlaybackControl.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Row { + id: root + spacing: controlBar.margin + + property bool isPlaybackEnabled: false + property bool isPlaying: false + + signal playButtonPressed() + + ImageButton { + id: playButton + enabled: isPlaybackEnabled + imageSource: !isPlaying ? "images/PlayButton.png" : "images/PauseButton.png" + anchors.verticalCenter: root.verticalCenter + onClicked: { + playButtonPressed(); + } + } +} diff --git a/basicsuite/qt5-everywhere/demos/video/ScrollBar.qml b/basicsuite/qt5-everywhere/demos/video/ScrollBar.qml new file mode 100644 index 0000000..8ac0d31 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/ScrollBar.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + property real position + property real pageSize + + // A light, semi-transparent background + Rectangle { + id: background + anchors.fill: parent + radius: width/2 - 1 + color: "transparent" + } + + Rectangle { + x: scrollBar.position * (scrollBar.width-2) + 1 + y: 1 + width: scrollBar.pageSize * (scrollBar.width-2) + height: parent.height + radius: height/2 - 1 + color: "#22aa22" + } +} diff --git a/basicsuite/qt5-everywhere/demos/video/SeekControl.qml b/basicsuite/qt5-everywhere/demos/video/SeekControl.qml new file mode 100644 index 0000000..2e037e3 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/SeekControl.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + property int position: 0 + property int duration: 0 + property bool seekable: false + property alias pressed : seekSlider.pressed + property bool enabled + + signal seekValueChanged(int newPosition) + + onPositionChanged: { + elapsedText.text = formatTime(position); + seekSlider.value = position; + } + + onDurationChanged: { + remainingText.text = formatTime(duration); + } + + Text { + id: elapsedText + anchors.verticalCenter: seekSlider.verticalCenter + anchors.left: root.left + verticalAlignment: Text.AlignVCenter + height: parent.height + text: "00:00" + font.pixelSize: height * 0.4 + color: "#cccccc" + } + + Slider { + id: seekSlider + anchors.left: elapsedText.right + anchors.right: remainingText.left + anchors.verticalCenter: root.verticalCenter + mutable: root.seekable + enabled: root.enabled + height: parent.height + + minimum: 0.0 + maximum: root.duration !== 0 ? root.duration : 1 + + onValueChangedByHandle: { + seekValueChanged(newValue); + applicationWindow.resetTimer() + } + } + + Text { + id: remainingText + anchors.verticalCenter: seekSlider.verticalCenter + anchors.right: root.right + verticalAlignment: Text.AlignVCenter + height: parent.height + text: "00:00" + font.pixelSize: height * 0.4 + color: "#cccccc" + } + + function formatTime(time) { + time = time / 1000 + var hours = Math.floor(time / 3600); + time = time - hours * 3600; + var minutes = Math.floor(time / 60); + var seconds = Math.floor(time - minutes * 60); + + if (hours > 0) + return formatTimeBlock(hours) + ":" + formatTimeBlock(minutes) + ":" + formatTimeBlock(seconds); + else + return formatTimeBlock(minutes) + ":" + formatTimeBlock(seconds); + + } + + function formatTimeBlock(time) { + if (time === 0) + return "00" + if (time < 10) + return "0" + time; + else + return time.toString(); + } +} diff --git a/basicsuite/qt5-everywhere/demos/video/Slider.qml b/basicsuite/qt5-everywhere/demos/video/Slider.qml new file mode 100644 index 0000000..cc45537 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/Slider.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: slider + + anchors.leftMargin: handleBack.radius + anchors.rightMargin: handleBack.radius + + // value is read/write. + property real value: 0 + property real maximum: 1 + property real minimum: 0 + property int xMax: width - handle.width + onXMaxChanged: updatePos() + onMinimumChanged: updatePos() + onValueChanged: if (!pressed) updatePos() + property bool mutable: true + property alias pressed : backgroundMouse.pressed + + signal valueChangedByHandle(int newValue) + + function updatePos() { + if (maximum > minimum) { + var pos = 0 + (value - minimum) * slider.xMax / (maximum - minimum); + pos = Math.min(pos, width - handle.width - 0); + pos = Math.max(pos, 0); + handle.x = pos; + } else { + handle.x = 0; + } + } + + Rectangle { + id: background + width: slider.width + anchors.verticalCenter: slider.verticalCenter + height: 2 + color: "#666666" + + MouseArea { + id: backgroundMouse + anchors.fill: parent + anchors.topMargin: -24 + anchors.bottomMargin: -24 + enabled: slider.mutable + drag.target: handle + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: slider.xMax + onPressedChanged: { + value = Math.max(minimum, Math.min(maximum, (maximum - minimum) * (mouseX - handle.width/2) / slider.xMax + minimum)); + valueChangedByHandle(value); + updatePos(); + } + onPositionChanged: { + value = Math.max(minimum, Math.min(maximum, (maximum - minimum) * (mouseX - handle.width/2) / slider.xMax + minimum)); + valueChangedByHandle(value); + } + onWheel: { + value = Math.max(minimum, Math.min(maximum, value + (wheel.angleDelta.y > 0 ? 1 : -1) * (10 / slider.xMax) * (slider.maximum - slider.minimum))); + valueChangedByHandle(value); + updatePos(); + } + } + } + + Rectangle { + id: progress + height: 5 + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.right: handle.right + anchors.rightMargin: handle.width / 2 + visible: slider.enabled + color: "#98c66c" + } + + Rectangle { + id: handleBack + width: Math.max(10, Math.min(50, slider.height)) + height: width + radius: width / 2 + color: "#8898c66c" + antialiasing: true + anchors.centerIn: handle + visible: handle.visible + } + + Rectangle { + id: handle + width: Math.max(3,handleBack.height / 3) + height: width + radius: width / 2 + antialiasing: true + color: "#98c66c" + anchors.verticalCenter: background.verticalCenter + visible: slider.enabled + } +} + diff --git a/basicsuite/qt5-everywhere/demos/video/VideoDelegate.qml b/basicsuite/qt5-everywhere/demos/video/VideoDelegate.qml new file mode 100644 index 0000000..fedc9f4 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/VideoDelegate.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: delegate + height: grid.cellHeight + width: grid.cellWidth + property int tileMargin: videoSelector.tileMargin + + signal videoSelected(string link) + + Rectangle { + anchors.left: parent.left + anchors.top: parent.top + anchors.topMargin: parent.tileMargin/2 + width: parent.width - tileMargin + height: parent.height - tileMargin + color: videoSelector.tileBackground + + MouseArea { + anchors.fill: parent + onClicked: { + grid.currentIndex = index + delegate.videoSelected(link) + } + } + + states: [ + State { + name: "selected" + when: delegate.GridView.isCurrentItem + } + ] + + + Image { + id: iconImage + source: thumbnail + width: parent.width + height: parent.height + } + + Rectangle{ + width: parent.width + height: titleText.height + tileMargin + anchors.top: titleText.top + anchors.bottom: parent.bottom + color: "Black" + opacity: 0.5 + visible: iconImage.source + + } + + Text { + id: titleText + anchors.left: parent.left + anchors.leftMargin: tileMargin/3 + anchors.bottom: parent.bottom + anchors.bottomMargin: tileMargin/3 + anchors.right: parent.right + anchors.rightMargin: tileMargin/3 + + color: videoSelector.textColor + text: title + width: parent.width; + wrapMode: Text.WordWrap; + smooth: true + font { family: videoSelector.uiFont; pixelSize: videoSelector.tileFontSize } + } + } +} + diff --git a/basicsuite/qt5-everywhere/demos/video/VideoSelector.qml b/basicsuite/qt5-everywhere/demos/video/VideoSelector.qml new file mode 100644 index 0000000..8ce8d83 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/VideoSelector.qml @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Item { + id: videoSelector + + property int tileHeight: parseInt(grid.height / 2) + property int tileMargin: tileHeight * 0.1 + property int tileFontSize: tileHeight * 0.08 + property string tileBackground: "#262626" + property string textColor: "white" + property string uiFont: "Segoe UI" + + signal selectVideo(string link) + + state: "VISIBLE" + + onOpacityChanged: { + if (state === "HIDDEN" && opacity <= 0.05) + visible = false; + } + + XmlListModel { + id: videoModel + source: "http://qt-project.org/uploads/videos/qt5_videos.xml" + query: "/videolist/item" + XmlRole { name: "thumbnail"; query: "thumbnail/string()" } + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + + onStatusChanged: { + if (status == XmlListModel.Ready) { + networkErrorBox.opacity = 0.0 + } else if (status == XmlListModel.Error) { + networkErrorBox.opacity = 1.0 + } + } + } + + Item { + id: networkErrorBox + opacity: 0 + anchors.fill: parent + + Text { + anchors.centerIn: parent + text: qsTr("Sorry! No network connection") + font.family: uiFont; + font.pixelSize: tileFontSize * 2; + color: textColor + smooth: true + } + } + + // Grid view + GridView { + id: grid + anchors.fill: parent + flow: GridView.TopToBottom + cellHeight: tileHeight + cellWidth: parseInt(tileHeight * 1.5) + cacheBuffer: cellWidth + clip: false + focus: true + model: videoModel + delegate: VideoDelegate { onVideoSelected: videoSelector.selectVideo(link); } + + // Only show the scrollbars when the view is moving. + states: State { + when: grid.movingHorizontally + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + ScrollBar { + id: horizontalScrollBar + width: parent.width; height: 6 + anchors.bottom: parent.bottom + anchors.left: parent.left + opacity: 0 + position: grid.visibleArea.xPosition + pageSize: grid.visibleArea.widthRatio + } + + function hide() { + videoSelector.state = "HIDDEN"; + } + + function show() { + videoSelector.visible = true; + videoSelector.state = "VISIBLE"; + } + + states: [ + State { + name: "HIDDEN" + PropertyChanges { + target: videoSelector + opacity: 0.0 + } + }, + State { + name: "VISIBLE" + PropertyChanges { + target: videoSelector + opacity: 0.95 + } + } + ] + + transitions: [ + Transition { + from: "HIDDEN" + to: "VISIBLE" + NumberAnimation { + id: showAnimation + target: videoSelector + properties: "opacity" + from: 0.0 + to: 1.0 + duration: 200 + } + }, + Transition { + from: "VISIBLE" + to: "HIDDEN" + NumberAnimation { + id: hideAnimation + target: videoSelector + properties: "opacity" + from: 0.95 + to: 0.0 + duration: 200 + } + } + ] +} diff --git a/basicsuite/qt5-everywhere/demos/video/VolumeControl.qml b/basicsuite/qt5-everywhere/demos/video/VolumeControl.qml new file mode 100644 index 0000000..4754951 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/VolumeControl.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property alias volume: volumeSlider.value + + //Volume Controls + ImageButton { + id: volumeDown + height: parent.height * 0.5 + imageSource: "images/VolumeDown.png" + anchors.verticalCenter: root.verticalCenter + anchors.left: root.left + onClicked: { + root.volume = 0.0; + } + } + Slider { + id: volumeSlider + anchors.left: volumeDown.right + anchors.right: volumeUp.left + height: root.height + maximum: 1.0 + minimum: 0.0 + anchors.verticalCenter: root.verticalCenter + anchors.verticalCenterOffset: 1 + } + + ImageButton { + id: volumeUp + height: parent.height * 0.5 + imageSource: "images/VolumeUp.png" + anchors.verticalCenter: root.verticalCenter + anchors.verticalCenterOffset: 1 + anchors.right: root.right + onClicked: { + root.volume = 1.0 + } + } +} diff --git a/basicsuite/qt5-everywhere/demos/video/images/CloseButton.png b/basicsuite/qt5-everywhere/demos/video/images/CloseButton.png Binary files differnew file mode 100644 index 0000000..24407fe --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/CloseButton.png diff --git a/basicsuite/qt5-everywhere/demos/video/images/PauseButton.png b/basicsuite/qt5-everywhere/demos/video/images/PauseButton.png Binary files differnew file mode 100644 index 0000000..b58ceb4 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/PauseButton.png diff --git a/basicsuite/qt5-everywhere/demos/video/images/PlayButton.png b/basicsuite/qt5-everywhere/demos/video/images/PlayButton.png Binary files differnew file mode 100644 index 0000000..247fe32 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/PlayButton.png diff --git a/basicsuite/qt5-everywhere/demos/video/images/RateButtonForward.png b/basicsuite/qt5-everywhere/demos/video/images/RateButtonForward.png Binary files differnew file mode 100644 index 0000000..ebfca0d --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/RateButtonForward.png diff --git a/basicsuite/qt5-everywhere/demos/video/images/RateButtonReverse.png b/basicsuite/qt5-everywhere/demos/video/images/RateButtonReverse.png Binary files differnew file mode 100644 index 0000000..1837bfd --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/RateButtonReverse.png diff --git a/basicsuite/qt5-everywhere/demos/video/images/StopButton.png b/basicsuite/qt5-everywhere/demos/video/images/StopButton.png Binary files differnew file mode 100644 index 0000000..76bcbc8 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/StopButton.png diff --git a/basicsuite/qt5-everywhere/demos/video/images/VolumeDown.png b/basicsuite/qt5-everywhere/demos/video/images/VolumeDown.png Binary files differnew file mode 100644 index 0000000..38b1013 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/VolumeDown.png diff --git a/basicsuite/qt5-everywhere/demos/video/images/VolumeUp.png b/basicsuite/qt5-everywhere/demos/video/images/VolumeUp.png Binary files differnew file mode 100644 index 0000000..cffe961 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/images/VolumeUp.png diff --git a/basicsuite/qt5-everywhere/demos/video/main.qml b/basicsuite/qt5-everywhere/demos/video/main.qml new file mode 100644 index 0000000..5987843 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/main.qml @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtMultimedia 5.0 + +Rectangle { + id: applicationWindow + focus: true + color: "black" + anchors.fill:parent + + MouseArea { + id: mouseActivityMonitor + anchors.fill: parent + + hoverEnabled: true + onClicked: { + if (controlBar.state === "VISIBLE") { + controlBar.hide(); + } else { + controlBar.show(); + controlBarTimer.restart(); + } + } + } + + signal resetTimer + onResetTimer: { + controlBar.show(); + controlBarTimer.restart(); + } + + Content { + id: content + anchors.fill: parent + } + + VideoSelector { + id: videoSelector + anchors.fill: parent + anchors.margins: applicationWindow.width * 0.02 + visible: true + onSelectVideo: { + videoSelector.hide() + content.openVideo(link) + content.videoPlayer.play() + } + onVisibleChanged: { + if (visible) + controlBar.hide() + else + controlBar.show() + } + } + + Timer { + id: controlBarTimer + interval: 4000 + running: false + + onTriggered: hideToolBars(); + } + + ControlBar { + id: controlBar + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: applicationWindow.bottom + mediaPlayer: content.videoPlayer.mediaPlayer + } + + Component.onCompleted: { + controlBar.hide() + } + + property real volumeBeforeMuted: 1.0 + + Keys.onPressed: { + applicationWindow.resetTimer(); + if (event.key === Qt.Key_Up || event.key === Qt.Key_VolumeUp) { + content.videoPlayer.mediaPlayer.volume = Math.min(1, content.videoPlayer.mediaPlayer.volume + 0.1); + return; + } else if (event.key === Qt.Key_Down || event.key === Qt.Key_VolumeDown) { + if (event.modifiers & Qt.ControlModifier) { + if (content.videoPlayer.mediaPlayer.volume) { + volumeBeforeMuted = content.videoPlayer.mediaPlayer.volume; + content.videoPlayer.mediaPlayer.volume = 0 + } else { + content.videoPlayer.mediaPlayer.volume = volumeBeforeMuted; + } + } else { + content.videoPlayer.mediaPlayer.volume = Math.max(0, content.videoPlayer.mediaPlayer.volume - 0.1); + } + return; + } + + // What's next should be handled only if there's a loaded media + if (content.videoPlayer.mediaPlayer.status !== MediaPlayer.Loaded + && content.videoPlayer.mediaPlayer.status !== MediaPlayer.Buffered) + return; + + if (event.key === Qt.Key_Space) { + if (content.videoPlayer.mediaPlayer.playbackState === MediaPlayer.PlayingState) + content.videoPlayer.mediaPlayer.pause() + else if (content.videoPlayer.mediaPlayer.playbackState === MediaPlayer.PausedState + || content.videoPlayer.mediaPlayer.playbackState === MediaPlayer.StoppedState) + content.videoPlayer.mediaPlayer.play() + } else if (event.key === Qt.Key_Left) { + content.videoPlayer.mediaPlayer.seek(Math.max(0, content.videoPlayer.mediaPlayer.position - 30000)); + return; + } else if (event.key === Qt.Key_Right) { + content.videoPlayer.mediaPlayer.seek(Math.min(content.videoPlayer.mediaPlayer.duration, content.videoPlayer.mediaPlayer.position + 30000)); + return; + } + } + + function hideToolBars() { + if (!controlBar.isMouseAbove && content.videoPlayer.isPlaying) + controlBar.hide(); + } + +} diff --git a/basicsuite/qt5-everywhere/demos/video/qt5_video_jens.png b/basicsuite/qt5-everywhere/demos/video/qt5_video_jens.png Binary files differnew file mode 100644 index 0000000..84f3bce --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/qt5_video_jens.png diff --git a/basicsuite/qt5-everywhere/demos/video/qt5_video_kenneth.png b/basicsuite/qt5-everywhere/demos/video/qt5_video_kenneth.png Binary files differnew file mode 100644 index 0000000..eecb297 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/qt5_video_kenneth.png diff --git a/basicsuite/qt5-everywhere/demos/video/qt5_video_lars.png b/basicsuite/qt5-everywhere/demos/video/qt5_video_lars.png Binary files differnew file mode 100644 index 0000000..51e0701 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/qt5_video_lars.png diff --git a/basicsuite/qt5-everywhere/demos/video/qt5_video_samuel.png b/basicsuite/qt5-everywhere/demos/video/qt5_video_samuel.png Binary files differnew file mode 100644 index 0000000..1ed97c1 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/qt5_video_samuel.png diff --git a/basicsuite/qt5-everywhere/demos/video/qt5_video_simon.png b/basicsuite/qt5-everywhere/demos/video/qt5_video_simon.png Binary files differnew file mode 100644 index 0000000..583c564 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/qt5_video_simon.png diff --git a/basicsuite/qt5-everywhere/demos/video/qt5_video_thiago.png b/basicsuite/qt5-everywhere/demos/video/qt5_video_thiago.png Binary files differnew file mode 100644 index 0000000..abf8522 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/qt5_video_thiago.png diff --git a/basicsuite/qt5-everywhere/demos/video/qt5_videos.xml b/basicsuite/qt5-everywhere/demos/video/qt5_videos.xml new file mode 100644 index 0000000..420e476 --- /dev/null +++ b/basicsuite/qt5-everywhere/demos/video/qt5_videos.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?>
+<videolist>
+ <item>
+ <title>Lars Knoll: The Making of Qt 5</title>
+ <thumbnail>qt5_video_lars.png</thumbnail>
+ <link>http://download.qt-project.org/learning/videos/Lars_Knoll_The_Making_of_Qt_5.mp4</link>
+ </item>
+ <item>
+ <title>Qt 5: Jens Bache-Wiig on Qt 5 and Qt Quick</title>
+ <thumbnail>qt5_video_jens.png</thumbnail>
+ <link>http://download.qt-project.org/learning/videos/Qt5_Jens_Bache-Wiig_on_Qt5_Qt_Quick.mp4</link>
+ </item>
+ <item>
+ <title>Qt 5: Simon Hausmann on Qt WebKit</title>
+ <thumbnail>qt5_video_simon.png</thumbnail>
+ <link>http://download.qt-project.org/learning/videos/Qt_5_Simon_Hausmann_on_Qt_WebKit.mp4</link>
+ </item>
+ <item>
+ <title>Qt 5: Qt Developer Kenneth Christiansen on Qt WebKit</title>
+ <thumbnail>qt5_video_kenneth.png</thumbnail>
+ <link>http://download.qt-project.org/learning/videos/Qt5_Kenneth_Christiansen_on_Qt_WebKit.mp4</link>
+ </item>
+ <item>
+ <title>Qt 5: Thiago Macieira on Qt Core</title>
+ <thumbnail>qt5_video_thiago.png</thumbnail>
+ <link>http://download.qt-project.org/learning/videos/Qt5_Thiago_Macieira_on_Qt_Core.mp4</link>
+ </item>
+ <item>
+ <title>Qt 5: Samuel Rodal on Qt GUI, Qt Quick and Qt Open GL</title>
+ <thumbnail>qt5_video_samuel.png</thumbnail>
+ <link>http://download.qt-project.org/learning/videos/Qt5_Samuel_Rodal_on_Qt_GUI_OpenGL.mp4</link>
+ </item>
+</videolist>
|