|
| 1 | +/* |
| 2 | + * Project: PiOmxTextures |
| 3 | + * Author: Luca Carlon |
| 4 | + * Date: 08.08.2015 |
| 5 | + * |
| 6 | + * Copyright (c) 2012-2015 Luca Carlon. All rights reserved. |
| 7 | + * |
| 8 | + * This file is part of PiOmxTextures. |
| 9 | + * |
| 10 | + * PiOmxTextures is free software: you can redistribute it and/or modify |
| 11 | + * it under the terms of the GNU General Public License as published by |
| 12 | + * the Free Software Foundation, either version 3 of the License, or |
| 13 | + * (at your option) any later version. |
| 14 | + * |
| 15 | + * PiOmxTextures is distributed in the hope that it will be useful, |
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | + * GNU General Public License for more details. |
| 19 | + * |
| 20 | + * You should have received a copy of the GNU General Public License |
| 21 | + * along with PiOmxTextures. If not, see <http://www.gnu.org/licenses/>. |
| 22 | + */ |
| 23 | + |
| 24 | +import QtQuick 2.0 |
| 25 | +import QtQml 2.2 |
| 26 | +import QtMultimedia 5.0 |
| 27 | + |
| 28 | +Rectangle { |
| 29 | + property var videoUris: [] |
| 30 | + property var audioUris: [] |
| 31 | + property int videoIndex: 0 |
| 32 | + property int audioIndex: 0 |
| 33 | + |
| 34 | + color: "red" |
| 35 | + |
| 36 | + Component.onCompleted: { |
| 37 | + var arguments = Qt.application.arguments; |
| 38 | + if (arguments.length < 6) { |
| 39 | + console.log("Too few arguments."); |
| 40 | + Qt.quit(); |
| 41 | + } |
| 42 | + |
| 43 | + videoUris.push(arguments[2]); |
| 44 | + videoUris.push(arguments[3]); |
| 45 | + audioUris.push(arguments[4]); |
| 46 | + audioUris.push(arguments[5]); |
| 47 | + |
| 48 | + nextVideo(video1); |
| 49 | + nextVideo(video2); |
| 50 | + nextAudio(audio); |
| 51 | + } |
| 52 | + |
| 53 | + Video { |
| 54 | + id: video1 |
| 55 | + width: 500 |
| 56 | + height: 450 |
| 57 | + x: parent.width/3 - width/2 |
| 58 | + y: parent.height/2 - height/2 |
| 59 | + autoPlay: false |
| 60 | + onStopped: nextVideo(video1) |
| 61 | + } |
| 62 | + |
| 63 | + Video { |
| 64 | + id: video2 |
| 65 | + width: 500 |
| 66 | + height: 450 |
| 67 | + x: parent.width/3*2 - width/2 |
| 68 | + y: parent.height/2 - height/2 |
| 69 | + autoPlay: false |
| 70 | + onStopped: nextVideo(video2) |
| 71 | + } |
| 72 | + |
| 73 | + Audio { |
| 74 | + id: audio |
| 75 | + source: uri3 |
| 76 | + autoPlay: false |
| 77 | + onStopped: nextAudio(audio) |
| 78 | + } |
| 79 | + |
| 80 | + //Timer { |
| 81 | + // interval: 500 |
| 82 | + // running: true; repeat: true |
| 83 | + // onTriggered: { |
| 84 | + // console.log("Position video1: " + video1.position + "."); |
| 85 | + // console.log("Position video2: " + video2.position + "."); |
| 86 | + // console.log("Position audio: " + audio.position + "."); |
| 87 | + // } |
| 88 | + //} |
| 89 | + |
| 90 | + Timer { |
| 91 | + interval: 5000 |
| 92 | + running: true; repeat: true |
| 93 | + onTriggered: { |
| 94 | + console.log("Switching audio..."); |
| 95 | + audio.stop(); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + function nextVideo(element) { |
| 100 | + element.source = videoUris[videoIndex++%2]; |
| 101 | + element.play(); |
| 102 | + } |
| 103 | + |
| 104 | + function nextAudio(element) { |
| 105 | + element.source = audioUris[audioIndex++%2]; |
| 106 | + element.play(); |
| 107 | + } |
| 108 | +} |
0 commit comments