Warning, /multimedia/audiotube/src/qtmpris/example/qml/player.qml is written in an unsupported language. File is not indexed.
0001 //SPDX-FileCopyrightText: 2015 Jolla Ltd. <valerio.valerio@jolla.com> 0002 //SPDX-FileContributor: Andres Gomez 0003 // 0004 //SPDX-License-Identifier: LGPL-2.1-or-later 0005 0006 0007 import QtQuick 2.0 0008 import org.nemomobile.qtmpris 1.0 0009 0010 Item { 0011 id: mainItem 0012 0013 anchors.fill: parent 0014 0015 Column { 0016 id: column 0017 0018 x: (parent.width - width) * 0.5 0019 width: parent.width * 0.75 0020 0021 Row { 0022 MouseArea { 0023 width: column.parent.width * 0.25 0024 height: width 0025 0026 onClicked: mprisPlayer.playbackStatus = Mpris.Stopped 0027 0028 Text { 0029 anchors.centerIn: parent 0030 text: "Stop" 0031 } 0032 } 0033 MouseArea { 0034 width: column.parent.width * 0.25 0035 height: width 0036 0037 onClicked: mprisPlayer.playbackStatus = Mpris.Playing 0038 0039 Text { 0040 anchors.centerIn: parent 0041 text: "Play" 0042 } 0043 } 0044 MouseArea { 0045 width: column.parent.width * 0.25 0046 height: width 0047 0048 onClicked: mprisPlayer.playbackStatus = Mpris.Paused 0049 0050 Text { 0051 anchors.centerIn: parent 0052 text: "Pause" 0053 } 0054 } 0055 } 0056 0057 Row { 0058 0059 width: parent.width 0060 height: artistSet.height 0061 0062 Text { 0063 id: artistLabel 0064 0065 height: parent.height 0066 text: "Artist: " 0067 verticalAlignment: Text.AlignVCenter 0068 } 0069 0070 TextInput { 0071 id: artistInput 0072 0073 width: parent.width - artistLabel.width - artistSet.width 0074 height: parent.height 0075 verticalAlignment: Text.AlignVCenter 0076 } 0077 0078 MouseArea { 0079 id: artistSet 0080 0081 width: column.parent.width * 0.25 0082 height: width 0083 0084 onClicked: mprisPlayer.artist = artistInput.text 0085 0086 Text { 0087 anchors.centerIn: parent 0088 text: "Set" 0089 } 0090 } 0091 } 0092 0093 Row { 0094 0095 width: parent.width 0096 height: songSet.height 0097 0098 Text { 0099 id: songLabel 0100 0101 height: parent.height 0102 text: "Song: " 0103 verticalAlignment: Text.AlignVCenter 0104 } 0105 0106 TextInput { 0107 id: songInput 0108 0109 width: parent.width - songLabel.width - songSet.width 0110 height: parent.height 0111 verticalAlignment: Text.AlignVCenter 0112 } 0113 0114 MouseArea { 0115 id: songSet 0116 0117 width: column.parent.width * 0.25 0118 height: width 0119 0120 onClicked: mprisPlayer.song = songInput.text 0121 0122 Text { 0123 anchors.centerIn: parent 0124 text: "Set" 0125 } 0126 } 0127 } 0128 0129 Text { 0130 id: message 0131 0132 property string lastMessage 0133 0134 text: "Last Message was: " + lastMessage 0135 width: parent.width 0136 elide: Text.ElideRight 0137 } 0138 } 0139 0140 MprisPlayer { 0141 id: mprisPlayer 0142 0143 property string artist 0144 property string song 0145 0146 serviceName: "qtmpris" 0147 0148 // Mpris2 Root Interface 0149 identity: "QtMpris Example" 0150 supportedUriSchemes: ["file"] 0151 supportedMimeTypes: ["audio/x-wav", "audio/x-vorbis+ogg"] 0152 0153 // Mpris2 Player Interface 0154 canControl: true 0155 0156 canGoNext: true 0157 canGoPrevious: true 0158 canPause: playbackStatus == Mpris.Playing 0159 canPlay: playbackStatus != Mpris.Playing 0160 canSeek: false 0161 0162 playbackStatus: Mpris.Stopped 0163 loopStatus: Mpris.None 0164 shuffle: false 0165 volume: 1 0166 0167 onPauseRequested: message.lastMessage = "Pause requested" 0168 onPlayRequested: message.lastMessage = "Play requested" 0169 onPlayPauseRequested: message.lastMessage = "Play/Pause requested" 0170 onStopRequested: message.lastMessage = "Stop requested" 0171 onNextRequested: message.lastMessage = "Next requested" 0172 onPreviousRequested: message.lastMessage = "Previous requested" 0173 onSeekRequested: { 0174 message.lastMessage = "Seeked requested with offset - " + offset + " microseconds" 0175 emitSeeked() 0176 } 0177 onSetPositionRequested: { 0178 message.lastMessage = "Position requested to - " + position + " microseconds" 0179 emitSeeked() 0180 } 0181 onOpenUriRequested: message.lastMessage = "Requested to open uri \"" + url + "\"" 0182 0183 onLoopStatusRequested: { 0184 if (loopStatus == Mpris.None) { 0185 repeatSwitch.checked = false 0186 } else if (loopStatus == Mpris.Playlist) { 0187 repeatSwitch.checked = true 0188 } 0189 } 0190 onShuffleRequested: shuffleSwitch.checked = shuffle 0191 0192 onArtistChanged: { 0193 var metadata = mprisPlayer.metadata 0194 0195 metadata[Mpris.metadataToString(Mpris.Artist)] = [artist] // List of strings 0196 0197 mprisPlayer.metadata = metadata 0198 } 0199 0200 onSongChanged: { 0201 var metadata = mprisPlayer.metadata 0202 0203 metadata[Mpris.metadataToString(Mpris.Title)] = song // String 0204 0205 mprisPlayer.metadata = metadata 0206 } 0207 } 0208 }