1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-04 01:42:44 +00:00

Add track selection back

This commit is contained in:
Chris Josten 2021-08-23 01:46:57 +02:00
parent 5a24bdee59
commit 1aae311b9b
11 changed files with 306 additions and 57 deletions

View file

@ -19,13 +19,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import QtQuick 2.6
import Sailfish.Silica 1.0
import nl.netsoj.chris.Jellyfin 1.0
import nl.netsoj.chris.Jellyfin 1.0 as J
Column {
property var tracks
property var audioTracks
property var videoTracks
property var subtitleTracks
readonly property int videoTrack: videoSelector.currentItem ? videoSelector.currentItem._index : 0
readonly property int audioTrack: audioSelector.currentItem ? audioSelector.currentItem._index : 0
readonly property int subtitleTrack: subitleSelector.currentItem._index
ListModel {
id: videoModel
}
@ -40,13 +45,13 @@ Column {
ComboBox {
id: videoSelector
label: qsTr("Video track")
enabled: videoModel.count > 1
enabled: videoTracks.length > 1
menu: ContextMenu {
Repeater {
model: videoModel
model: videoTracks
MenuItem {
readonly property int _index: model.index
text: model.displayTitle
readonly property int _index: modelData.index
text: modelData.displayTitle
}
}
}
@ -55,13 +60,13 @@ Column {
ComboBox {
id: audioSelector
label: qsTr("Audio track")
enabled: audioModel.count > 1
enabled: audioTracks.length > 1
menu: ContextMenu {
Repeater {
model: audioModel
model: audioTracks
MenuItem {
readonly property int _index: model.index
text: model.displayTitle
readonly property int _index: modelData.index
text: modelData.displayTitle
}
}
}
@ -70,7 +75,7 @@ Column {
ComboBox {
id: subitleSelector
label: qsTr("Subtitle track")
enabled: subtitleModel.count > 0
enabled: subtitleTracks.length> 0
menu: ContextMenu {
MenuItem {
readonly property int _index: -1
@ -78,39 +83,12 @@ Column {
text: qsTr("Off")
}
Repeater {
model: subtitleModel
model: subtitleTracks
MenuItem {
readonly property int _index: model.index
text: model.displayTitle
readonly property int _index: modelData.index
text: modelData.displayTitle
}
}
}
}
onTracksChanged: {
audioModel.clear()
subtitleModel.clear()
if (typeof tracks === "undefined") {
console.log("tracks undefined")
return
}
console.log(tracks)
for(var i = 0; i < tracks.length; i++) {
var track = tracks[i];
switch(track.type) {
case MediaStream.Video:
videoModel.append(track)
break;
case MediaStream.Audio:
audioModel.append(track)
break;
case MediaStream.Subtitle:
subtitleModel.append(track)
break;
default:
console.log("Ignored " + track.displayTitle + "(" + track.type + ")")
break;
}
}
}
}

View file

@ -26,8 +26,9 @@ Rectangle {
id: videoError
//FIXME: Once QTBUG-10822 is resolved, change to J.PlaybackManager
property var player
property bool showError: false
color: pal.palette.overlayBackgroundColor
opacity: player.error === MediaPlayer.NoError ? 0.0 : 1.0
opacity: showError ? 1.0 : 0.0
Behavior on opacity { FadeAnimator {} }
SilicaItem {
@ -88,6 +89,20 @@ Rectangle {
text: qsTr("Retry")
onClicked: player.play()
}
Button {
text: qsTr("Hide")
onClicked: showError = false
}
}
}
Connections {
target: player
onErrorChanged: {
if (player.error !== MediaPlayer.NoError) {
showError = true
}
}
}

View file

@ -76,7 +76,13 @@ BaseDetailPage {
VideoTrackSelector {
id: trackSelector
width: parent.width
tracks: itemData.mediaStreams
audioTracks: itemData.audioStreams
videoTracks: itemData.videoStreams
subtitleTracks: itemData.subtitleStreams
}
Label {
text: "Video %1, audio %2, subtitle %3".arg(trackSelector.videoTrack).arg(trackSelector.audioTrack).arg(trackSelector.subtitleTrack)
}
}
}