summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2016-05-30 13:04:56 +0200
committerDominik Holland <dominik.holland@pelagicore.com>2016-06-08 17:18:10 +0000
commitf3399ea6ba90fa5fbdb6c7a786c601e83a73e4e1 (patch)
treef98445a412121f11cc16f734231fe6fdd1620689 /examples
parentbbcd9224a2033d2d015e6e580a18dedddaeb1c35 (diff)
downloadqtivi-f3399ea6ba90fa5fbdb6c7a786c601e83a73e4e1.tar.gz
Added a MediaPlayer example and a simulation backend
The simulation backend starts to implement the mediaplayer functionality but is not yet fully complete. It also provides a backend for the SearchAndBrowseModel to browse thru to available media content and select a track for playback Task-number: QTAUTO-87 Task-number: QTAUTO-88 Change-Id: Iffc6abdfd10bfa58933347512fe7866f662ad0b6 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro3
-rw-r--r--examples/media/media.pro2
-rw-r--r--examples/media/mediaplayer/main.cpp64
-rw-r--r--examples/media/mediaplayer/main.qml213
-rw-r--r--examples/media/mediaplayer/mediaplayer.pro16
-rw-r--r--examples/media/mediaplayer/qml.qrc5
6 files changed, 302 insertions, 1 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index ee83e25..aba798a 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
-SUBDIRS = vehiclefunctions
+SUBDIRS = vehiclefunctions \
+ media
qtHaveModule(geniviextras) {
SUBDIRS += geniviextras
}
diff --git a/examples/media/media.pro b/examples/media/media.pro
new file mode 100644
index 0000000..bf30a2c
--- /dev/null
+++ b/examples/media/media.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = mediaplayer
diff --git a/examples/media/mediaplayer/main.cpp b/examples/media/mediaplayer/main.cpp
new file mode 100644
index 0000000..1b4c909
--- /dev/null
+++ b/examples/media/mediaplayer/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD-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.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
diff --git a/examples/media/mediaplayer/main.qml b/examples/media/mediaplayer/main.qml
new file mode 100644
index 0000000..f7a1c3f
--- /dev/null
+++ b/examples/media/mediaplayer/main.qml
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD-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.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 1.5
+import QtQuick.Layouts 1.1
+import QtIvi 1.0
+import QtIvi.Media 1.0
+
+ApplicationWindow {
+ visible: true
+ width: 640
+ height: 480
+ title: qsTr("Media Player")
+
+ MediaPlayer {
+ id: mediaPlayer
+ }
+
+ SplitView {
+ id: splitView1
+ anchors.fill: parent
+
+ ColumnLayout {
+
+ RowLayout {
+ Label { text: "Artist:" }
+ Label { text: mediaPlayer.currentTrack.artist }
+ }
+
+ RowLayout {
+ Label { text: "Album:" }
+ Label { text: mediaPlayer.currentTrack.album }
+ }
+
+ RowLayout {
+ Label { text: "Title:" }
+ Label { text: mediaPlayer.currentTrack.title }
+ }
+
+ RowLayout {
+ Button {
+ text: "<-"
+ onClicked: mediaPlayer.previous()
+ }
+
+ Button {
+ text: "stop"
+ onClicked: mediaPlayer.stop()
+ }
+
+ Button {
+ text: ">"
+ onClicked: mediaPlayer.play()
+ }
+
+ Button {
+ text: "->"
+ onClicked: mediaPlayer.next()
+ }
+ }
+
+ ListView {
+ spacing: 8
+ clip: true
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+
+ model: mediaPlayer.playQueue
+
+ delegate: Rectangle {
+ width: ListView.view.width
+ height: column.height
+ color: "#efefef"
+
+ Column {
+ id: column
+ width: parent.width
+
+ Text { text: "Index: " + index }
+ Text { text: "Name: " + model.name }
+ Text { text: "Type: " + model.item.type }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+
+ }
+ }
+ }
+ }
+ }
+
+ ColumnLayout {
+
+ RowLayout {
+ Label { text: "filter:" }
+ TextField { id: filterEdit }
+ }
+
+ ListView {
+ spacing: 8
+ clip: true
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+
+ header: Rectangle {
+ width: ListView.view.width
+ height: searchModel.canGoBack ? 50 : 0
+ visible: height > 0
+ color: "#efefef"
+
+ Text {
+ anchors.centerIn: parent
+ text: "back"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ searchModel.goBack()
+ }
+ }
+ }
+
+ model: SearchAndBrowseModel {
+ id: searchModel
+ serviceObject: mediaPlayer.serviceObject
+ contentType: "artist"
+ loadingType: SearchAndBrowseModel.FetchMore
+ query: filterEdit.text
+ onQueryChanged: filterEdit.text = query
+ }
+
+ delegate: Rectangle {
+ width: ListView.view.width
+ height: column.height
+ color: "#efefef"
+
+ Column {
+ id: column
+ width: parent.width
+
+ Text { text: "Index: " + index }
+ Text { text: "Name: " + model.name }
+ Text { text: "Type: " + model.item.type }
+ Text { text: "CanForward: " + model.canGoForward }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (item.type === "track")
+ mediaPlayer.playQueue.insert(0, item)
+ else
+ searchModel.goForward(index, SearchAndBrowseModel.InModelNavigation)
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/media/mediaplayer/mediaplayer.pro b/examples/media/mediaplayer/mediaplayer.pro
new file mode 100644
index 0000000..25cd849
--- /dev/null
+++ b/examples/media/mediaplayer/mediaplayer.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+
+QT += qml quick widgets ivicore
+
+CONFIG += c++11
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/media/mediaplayer
+INSTALLS += target
diff --git a/examples/media/mediaplayer/qml.qrc b/examples/media/mediaplayer/qml.qrc
new file mode 100644
index 0000000..5f6483a
--- /dev/null
+++ b/examples/media/mediaplayer/qml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>