diff --git a/components/ItemGrid/LoadVideoContentTask.bs b/components/ItemGrid/LoadVideoContentTask.bs index fcea7c58..80e16447 100644 --- a/components/ItemGrid/LoadVideoContentTask.bs +++ b/components/ItemGrid/LoadVideoContentTask.bs @@ -175,6 +175,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s m.playbackInfo = meta.json end if + addAudioStreamsToVideo(video) if meta.live video.transcodeParams = { "MediaSourceId": m.playbackInfo.MediaSources[0].Id, @@ -355,6 +356,23 @@ sub addVideoContentURL(video, mediaSourceId, audio_stream_idx, fully_external) end if end sub + +' addAudioStreamsToVideo: Add audio stream data to video +' +' @param {dynamic} video component to add fullAudioData to +sub addAudioStreamsToVideo(video) + audioStreams = [] + mediaStreams = m.playbackInfo.MediaSources[0].MediaStreams + + for i = 0 to mediaStreams.Count() - 1 + if LCase(mediaStreams[i].Type) = "audio" + audioStreams.push(mediaStreams[i]) + end if + end for + + video.fullAudioData = audioStreams +end sub + sub addSubtitlesToVideo(video, meta) subtitles = sortSubtitles(meta.id, m.playbackInfo.MediaSources[0].MediaStreams) safesubs = subtitles["all"] diff --git a/components/RadioDialog.bs b/components/RadioDialog.bs index 9d79a0ee..05c55280 100644 --- a/components/RadioDialog.bs +++ b/components/RadioDialog.bs @@ -109,7 +109,8 @@ sub onContentDataChanged() m.radioOptions.selectedIndex = i end if - textLine = cardItem.CreateChild("SimpleLabel") + textLine = cardItem.CreateChild("ScrollingLabel") + textLine.maxWidth = "750" textLine.text = item.track.description cardItem.observeField("selected", "onItemSelected") i++ diff --git a/components/manager/ViewCreator.bs b/components/manager/ViewCreator.bs index 55b6275f..eaf66f9c 100644 --- a/components/manager/ViewCreator.bs +++ b/components/manager/ViewCreator.bs @@ -14,6 +14,7 @@ sub CreateVideoPlayerView() m.view.observeField("state", "onStateChange") m.view.observeField("selectPlaybackInfoPressed", "onSelectPlaybackInfoPressed") m.view.observeField("selectSubtitlePressed", "onSelectSubtitlePressed") + m.view.observeField("selectAudioPressed", "onSelectAudioPressed") mediaSourceId = m.global.queueManager.callFunc("getCurrentItem").mediaSourceId @@ -32,6 +33,36 @@ end sub ' Event Handlers ' ----------------- + +' onSelectAudioPressed: Display audio selection dialog +' +sub onSelectAudioPressed() + audioData = { + data: [] + } + + for each item in m.view.fullAudioData + + audioStreamItem = { + "Index": item.Index, + "IsExternal": item.IsExternal, + "Track": { + "description": item.DisplayTitle + }, + "Type": "audioselection" + } + + if m.view.audioIndex = item.Index + audioStreamItem.selected = true + end if + + audioData.data.push(audioStreamItem) + end for + + m.global.sceneManager.callFunc("radioDialog", tr("Select Audio"), audioData) + m.global.sceneManager.observeField("returnData", "onSelectionMade") +end sub + ' User requested subtitle selection popup sub onSelectSubtitlePressed() ' None is always first in the subtitle list @@ -85,6 +116,25 @@ sub onSelectionMade() if LCase(m.global.sceneManager.returnData.type) = "subtitleselection" processSubtitleSelection() + return + end if + + if LCase(m.global.sceneManager.returnData.type) = "audioselection" + processAudioSelection() + return + end if +end sub + + +' processAudioSelection: Audio track selection handler +' +sub processAudioSelection() + selectedAudioTrack = m.global.sceneManager.returnData + + if isValid(selectedAudioTrack) + if isValid(selectedAudioTrack.index) + m.view.audioIndex = selectedAudioTrack.index + end if end if end sub diff --git a/components/video/OSD.xml b/components/video/OSD.xml index b8ff7ff0..2e1328cf 100644 --- a/components/video/OSD.xml +++ b/components/video/OSD.xml @@ -8,6 +8,7 @@ + diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index c45df798..8c1bc9d4 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -32,6 +32,7 @@ sub init() m.top.observeField("state", "onState") m.top.observeField("content", "onContentChange") m.top.observeField("selectedSubtitle", "onSubtitleChange") + m.top.observeField("audioIndex", "onAudioIndexChange") ' Custom Caption Function m.top.observeField("allowCaptions", "onAllowCaptionsChange") @@ -163,6 +164,12 @@ sub handleShowSubtitleMenuAction() m.top.selectSubtitlePressed = true end sub +' handleShowAudioMenuAction: Handles action to show audio selection menu +' +sub handleShowAudioMenuAction() + m.top.selectAudioPressed = true +end sub + ' handleShowVideoInfoPopupAction: Handles action to show video info popup ' sub handleShowVideoInfoPopupAction() @@ -204,6 +211,11 @@ sub onOSDAction() return end if + if action = "showaudiomenu" + handleShowAudioMenuAction() + return + end if + if action = "showvideoinfopopup" handleShowVideoInfoPopupAction() return @@ -274,6 +286,24 @@ sub onSubtitleChange() m.top.control = "stop" m.LoadMetaDataTask.selectedSubtitleIndex = m.top.SelectedSubtitle + m.LoadMetaDataTask.selectedAudioStreamIndex = m.top.audioIndex + m.LoadMetaDataTask.itemId = m.currentItem.id + m.LoadMetaDataTask.observeField("content", "onVideoContentLoaded") + m.LoadMetaDataTask.control = "RUN" +end sub + +' Event handler for when audioIndex changes +sub onAudioIndexChange() + ' Skip initial audio index setting + if m.top.position = 0 then return + + ' Save the current video position + m.global.queueManager.callFunc("setTopStartingPoint", int(m.top.position) * 10000000&) + + m.top.control = "stop" + + m.LoadMetaDataTask.selectedSubtitleIndex = m.top.SelectedSubtitle + m.LoadMetaDataTask.selectedAudioStreamIndex = m.top.audioIndex m.LoadMetaDataTask.itemId = m.currentItem.id m.LoadMetaDataTask.observeField("content", "onVideoContentLoaded") m.LoadMetaDataTask.control = "RUN" @@ -328,6 +358,7 @@ sub onVideoContentLoaded() m.top.container = videoContent[0].container m.top.mediaSourceId = videoContent[0].mediaSourceId m.top.fullSubtitleData = videoContent[0].fullSubtitleData + m.top.fullAudioData = videoContent[0].fullAudioData m.top.audioIndex = videoContent[0].audioIndex m.top.transcodeParams = videoContent[0].transcodeparams m.chapters = videoContent[0].chapters diff --git a/components/video/VideoPlayerView.xml b/components/video/VideoPlayerView.xml index bd35744d..2f7b67fe 100644 --- a/components/video/VideoPlayerView.xml +++ b/components/video/VideoPlayerView.xml @@ -3,6 +3,7 @@ + @@ -23,6 +24,7 @@ + diff --git a/images/icons/musicNote.png b/images/icons/musicNote.png new file mode 100644 index 00000000..2592230e Binary files /dev/null and b/images/icons/musicNote.png differ