blob: 2607ccb29c6481a0a40f2258838700c45b7d849f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
import QtQuick 2.0
import com.windriver.ammonitor 1.0
Item {
id :button
anchors.horizontalCenter: parent.horizontalCenter
width: 100
height: 100
property bool pressed: hitbox.pressed && hitbox.containsMouse
property var amCommandIF
property string amSource
property string amSink
property string mediaRole
property string audioFilePath
property int connectionID : 0
property string iconName
property string title : "no title"
Rectangle {
anchors.fill: parent
anchors.margins: 4
color: paplayer.playing?"darkGray":"lightGray"
radius: 10
border.width: 1
border.color: "gray"
Image {
id: icon
height: (pressed||paplayer.playing)?(parent.height/3):(parent.height/2)
fillMode: Image.PreserveAspectFit
anchors.horizontalCenter: parent.horizontalCenter
y: (parent.height - (height + titleText.height)) / 2
source: "images/icon_"+iconName+".png"
}
Image {
height: parent.height / 5
fillMode: Image.PreserveAspectFit
x: parent.width - width - (width/2)
y: (height/2)
source: "images/volume-up.png"
visible: paplayer.playing
}
Text {
id: titleText
anchors.top: icon.bottom
anchors.horizontalCenter: parent.horizontalCenter
text: title
font.pixelSize: parent.height / 6
}
Text {
id: descText
visible: pressed||paplayer.playing
anchors.top: titleText.bottom
anchors.horizontalCenter: parent.horizontalCenter
//text: "Connecting '"+amSource+"' to '"+amSink+"'"
text: amSource+" => "+amSink
font.pixelSize: parent.height / 10
}
PAPlayer {
id: paplayer
role: mediaRole
file: audioFilePath
source: amSource
sink: amSink
onPlayStateChanged: {
if(!playing && button.connectionID != 0) {
console.log('11 trying to disconnect AM connection: '+button.connectionID)
amCommandIF.disconnect(button.connectionID);
button.connectionID = 0
}
}
}
MouseArea {
id: hitbox
anchors.fill: parent
onClicked : {
if(paplayer.isPlaying()) {
console.log('trying to disconnect AM connection: '+button.connectionID)
if(button.connectionID != 0) {
if(amCommandIF.disconnect(button.connectionID))
paplayer.stop()
button.connectionID = 0
}
} else {
button.connectionID = amCommandIF.connect(amSource, amSink);
console.log('AM Connected: '+button.connectionID)
if(button.connectionID > 0)
paplayer.play()
}
}
}
}
}
|