X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=app%2FMediaPlayer.qml;h=25dea2c36ece7c19ea72a4dd2dc5c34bf68bb08c;hb=refs%2Ftags%2F5.1.0;hp=6f8d0db20f51f51b9f5e742afbde3fda19684ca3;hpb=2f046fbfad4193474332f716a1507b0da55f018a;p=apps%2Fmediaplayer.git diff --git a/app/MediaPlayer.qml b/app/MediaPlayer.qml index 6f8d0db..25dea2c 100644 --- a/app/MediaPlayer.qml +++ b/app/MediaPlayer.qml @@ -34,7 +34,7 @@ ApplicationWindow { property int position: 0 property string cover_art: "" - property string status: "" + property string status: "stopped" function time2str(value) { return Qt.formatTime(new Date(value), 'mm:ss') @@ -105,6 +105,11 @@ ApplicationWindow { if (data.Connected == "False") return + if (!bluetooth.av_connected && data.AVPConnected == "True") { + mediaplayer.pause() + player.status = "stopped" + } + bluetooth.connected = data.Connected == "True" bluetooth.av_connected = data.AVPConnected == "True" bluetooth.deviceAddress = data.Address @@ -303,22 +308,14 @@ ApplicationWindow { } ImageButton { id: play - offImage: './images/AGL_MediaPlayer_Player_Play.svg' - onClicked: { - if (bluetooth.av_connected) { - bluetooth.set_avrcp_controls("Play") - } else { - mediaplayer.play() - } - } states: [ State { - when: player.status == "playing" + when: !bluetooth.av_connected && player.status == "playing" PropertyChanges { target: play offImage: './images/AGL_MediaPlayer_Player_Pause.svg' onClicked: { - player.status = "" + player.status = "stopped" mediaplayer.pause() } } @@ -330,8 +327,23 @@ ApplicationWindow { offImage: './images/AGL_MediaPlayer_Player_Pause.svg' onClicked: bluetooth.set_avrcp_controls("Pause") } + }, + State { + when: !bluetooth.av_connected && player.status != "playing" + PropertyChanges { + target: play + offImage: './images/AGL_MediaPlayer_Player_Play.svg' + onClicked: mediaplayer.play() + } + }, + State { + when: bluetooth.av_connected && bluetooth.state != "playing" + PropertyChanges { + target: play + offImage: './images/AGL_MediaPlayer_Player_Play.svg' + onClicked: bluetooth.set_avrcp_controls("Play") + } } - ] } ImageButton {