-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
139 lines (121 loc) · 4.23 KB
/
main.qml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import QtQuick
import QtQuick.Controls
import QtMultimedia
Window {
id: root
width: 640
height: 480
visible: true
title: qsTr("Media Player")
property alias source: mediaPlayer.source
Popup {
id: mediaError
anchors.centerIn: Overlay.overlay
Text {
id: mediaErrorText
}
}
MediaPlayer {
id: mediaPlayer
videoOutput: videoOutput
audioOutput: AudioOutput {
id: audio
muted: playbackControl.muted
volume: playbackControl.volume
}
onMetaDataChanged: updateMetadata()
onActiveTracksChanged: updateMetadata()
onErrorOccurred: {
mediaErrorText.text = mediaPlayer.errorString
mediaError.open()
}
onTracksChanged: {
audioTracksInfo.read(mediaPlayer.audioTracks)
audioTracksInfo.selectedTrack = mediaPlayer.activeAudioTrack
videoTracksInfo.read(mediaPlayer.activeVideoTrack)
videoTracksInfo.selectedTrack = mediaPlayer.activeVideoTrack
subtitleTracksInfo.read(mediaPlayer.subtitleTrack)
subtitleTracksInfo.selectedTrack = mediaPlayer.activeSubtitleTrack
updateMetadata()
}
function updateMetadata() {
metadataInfo.clear()
metadataInfo.read(mediaPlayer.metaData)
metadataInfo.read(
mediaPlayer.audioTracks[mediaPlayer.activeAudioTrack])
metadataInfo.read(
mediaPlayer.videoTracks[mediaPlayer.activeVideoTrack])
}
}
VideoOutput {
id: videoOutput
property bool fullScreen: false
anchors.top: fullScreen ? parent.top : menuBar.bottom
anchors.bottom: playbackControl.top
anchors.left: parent.left
anchors.right: parent.right
TapHandler {
onDoubleTapped: {
parent.fullScreen ? showNormal() : showFullScreen()
parent.fullScreen = !parent.fullScreen
}
onTapped: {
metadataInfo.visible = false
audioTracksInfo.visible = false
videoTracksInfo.visible = false
subtitleTracksInfo.visible = false
}
}
}
MetadataInfo {
id: metadataInfo
anchors.right: parent.right
anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
visible: false
}
TracksInfo {
id: audioTracksInfo
anchors.right: parent.right
anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
visible: false
onSelectedTrackChanged: mediaPlayer.activeAudioTrack = audioTracksInfo.selectedTrack
}
TracksInfo {
id: videoTracksInfo
anchors.right: parent.right
anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
visible: false
onSelectedTrackChanged: mediaPlayer.activeVideoTrack = videoTracksInfo.selectedTrack
}
TracksInfo {
id: subtitleTracksInfo
anchors.right: parent.right
anchors.top: videoOutput.fullScreen ? parent.top : menuBar.bottom
anchors.bottom: playbackControl.opacity ? playbackControl.bottom : parent.bottom
visible: false
onSelectedTrackChanged: mediaPlayer.activeSubtitleTrack = subtitleTracksInfo.selectedTrack
}
PlayerMenuBar {
id: menuBar
anchors.left: parent.left
anchors.right: parent.right
visible: !videoOutput.fullScreen
mediaPlayer: mediaPlayer
videoOutput: videoOutput
metadataInfo: metadataInfo
audioTracksInfo: audioTracksInfo
videoTracksInfo: videoTracksInfo
subtitleTracksInfo: subtitleTracksInfo
onClosePlayer: root.close()
}
PlaybackControl {
id: playbackControl
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
mediaPlayer: mediaPlayer
}
}