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: radioPlayer.playlistIndex < radioPlayer.playlist.count -1 && radioPlayer._favorite
   canGoPrevious: radioPlayer.playlistIndex > 0  && radioPlayer._favorite
   canPause: radioPlayer.isPlaying ? true : false
   canPlay: radioPlayer.isPaused ? true : false
   canSeek: false
   hasTrackList: false
   loopStatus: Mpris.LoopNone
   shuffle: false
   volume: 1

   playbackStatus: {
       if (radioPlayer.isPlaying) Mpris.Playing;
       else if (radioPlayer.isPaused) Mpris.Paused;
       else Mpris.Stopped;
   }

   metaData {
       url: radioPlayer.source
       contributingArtist: radioPlayer.metaData.title
       title: radioPlayer._name
   }

   onNextRequested: radioPlayer.playNext()

   onPreviousRequested: radioPlayer.playPrev()

   onPauseRequested:{
       radioPlayer.pauseStream();
   }

   onPlayRequested: {
       radioPlayer.resumeStream();
   }
   onPlayPauseRequested: {
       radioPlayer.isPaused ? radioPlayer.playStream() : radioPlayer.pauseStream();
   }
   onStopRequested: {
       radioPlayer.pauseStream();
   }

   onOpenUriRequested: message.lastMessage = "Requested to open uri \"" + url + "\""
}
