Very simple early amber-mpris function
This commit is contained in:
parent
bafdfb72c6
commit
3e431edef9
@ -19,6 +19,7 @@ SOURCES += src/harbour-allradio.cpp
|
||||
DISTFILES += qml/harbour-allradio.qml \
|
||||
qml/cover/CoverPage.qml \
|
||||
qml/items/HeaderButton.qml \
|
||||
qml/items/RadioMprisPlayer.qml \
|
||||
qml/items/SleepTimer.qml \
|
||||
qml/pages/AboutPage.qml \
|
||||
qml/pages/AllRadio.qml \
|
||||
|
@ -2,6 +2,7 @@ import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import Nemo.Configuration 1.0 /////////
|
||||
import Nemo.Notifications 1.0 ///////////
|
||||
import Amber.Mpris 1.0
|
||||
import "pages"
|
||||
import "items"
|
||||
//import "radio-player"
|
||||
@ -9,6 +10,7 @@ import "items"
|
||||
import "helpers"
|
||||
//import "jupii"
|
||||
|
||||
// Check out Amber Mpris Qml !!!
|
||||
|
||||
ApplicationWindow
|
||||
{
|
||||
@ -23,11 +25,7 @@ ApplicationWindow
|
||||
property RadioBrowser radioBrowser : RadioBrowser {id:radioBrowser;parent: allRadio}
|
||||
property SleepTimer sleepTimer : SleepTimer {id:sleepTimer}
|
||||
|
||||
// property alias online: radioBrowser.online
|
||||
//property alias mediaPlayerPanel: playerPanel
|
||||
// property Media MediaPlayerPanel {id: mediaPlayerPanel}
|
||||
// property Jupii jupii: Jupii {id: jupii}
|
||||
|
||||
RadioMprisPlayer {id: radioMprisPlayer}
|
||||
MediaPlayerPanel {id: mediaPlayerPanel}
|
||||
ConfigurationGroup {id:settingsGroup;path: "/apps/harbour-allradio";ConfigurationGroup {id: allradioSettings;path: "/settings"}}
|
||||
Notification {id: notification;onClicked: console.log("Clicked")}
|
||||
|
67
qml/items/RadioMprisPlayer.qml
Normal file
67
qml/items/RadioMprisPlayer.qml
Normal file
@ -0,0 +1,67 @@
|
||||
import QtQuick 2.0
|
||||
import QtMultimedia 5.6
|
||||
import Amber.Mpris 1.0
|
||||
|
||||
MprisPlayer {
|
||||
id: mprisPlayer
|
||||
property string song: ""
|
||||
property string artist: "AllRadio"
|
||||
|
||||
serviceName: "harbour-allradio"
|
||||
|
||||
identity: "AllRadio2"
|
||||
supportedUriSchemes: ["file"]
|
||||
supportedMimeTypes: ["audio/x-wav", "audio/x-vorbis+ogg", "audio/mpeg", "audio/mp4a-latm", "audio/x-aiff"]
|
||||
|
||||
canControl: true
|
||||
|
||||
canGoNext: false //appstate.playlistIndex < appstate.playlist.count
|
||||
canGoPrevious: false // appstate.playlistIndex > 0
|
||||
canPause: radioPlayer.isPlaying ? true : false
|
||||
canPlay: radioPlayer.isPaused ? true : false
|
||||
|
||||
canSeek: false// playback.seekable
|
||||
hasTrackList: false
|
||||
|
||||
|
||||
loopStatus: Mpris.LoopNone
|
||||
shuffle: false
|
||||
volume: 1
|
||||
|
||||
playbackStatus: {
|
||||
if (radioPlayer.isPlaying) Mpris.Playing;
|
||||
else if (radioPlayer.isPaused) Mpris.Paused;
|
||||
else Mpris.Stopped;
|
||||
/* switch (radioPlayer.playbackState) {
|
||||
case Audio.PlayingState:
|
||||
return Mpris.Playing
|
||||
case Audio.PausedState:
|
||||
return Mpris.Paused
|
||||
default:
|
||||
return Mpris.Stopped
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
metaData {
|
||||
url: radioPlayer.source
|
||||
contributingArtist: radioPlayer.metaInfo
|
||||
title: radioPlayer._name
|
||||
}
|
||||
|
||||
onPauseRequested:{
|
||||
radioPlayer.pauseStream();
|
||||
}
|
||||
|
||||
onPlayRequested: {
|
||||
radioPlayer.resumeStream();
|
||||
}
|
||||
onPlayPauseRequested: {
|
||||
radioPlayer.pauseStream();
|
||||
}
|
||||
onStopRequested: {
|
||||
radioPlayer.pauseStream();
|
||||
}
|
||||
|
||||
onOpenUriRequested: message.lastMessage = "Requested to open uri \"" + url + "\""
|
||||
}
|
@ -24,6 +24,7 @@ MediaPlayer {
|
||||
property bool _favorite: false
|
||||
//--------------------------------
|
||||
// property bool videoP: false
|
||||
|
||||
property bool playerPageOpen: false
|
||||
// property bool jupiiOn: false
|
||||
property string radioId: ""
|
||||
@ -386,6 +387,32 @@ MediaPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
function updateMprisMetadata(){
|
||||
mprisPlayer.song = metaInfo ? metaInfo : ""
|
||||
mprisPlayer.artist = radioStation === "" ? "AllRadio" : radioStation
|
||||
updatePlaybackStatus()
|
||||
}
|
||||
|
||||
function updatePlaybackStatus (){
|
||||
switch (playMusic.playbackState) {
|
||||
case Audio.PlayingState:
|
||||
mprisPlayer.playbackStatus = Mpris.Playing
|
||||
break;
|
||||
|
||||
case Audio.PausedState:
|
||||
mprisPlayer.setCanPause(false)
|
||||
mprisPlayer.playbackStatus = Mpris.Paused
|
||||
break;
|
||||
case Audio.StoppedState:
|
||||
mprisPlayer.playbackStatus = Mpris.Paused
|
||||
break;
|
||||
default:
|
||||
mprisPlayer.playbackStatus = Mpris.Paused
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Component.onCompleted: {reloadDbData();loadRecentPlay()}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user