Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/data/SceneManager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
<field id="currentUser" type="string" onChange="updateUser" />
<field id="returnData" type="assocarray" />
<field id="dataReturned" type="boolean" />
<field id="currentSpeed" type="float" value="1.0"/>
</interface>
</component>
46 changes: 46 additions & 0 deletions components/manager/ViewCreator.bs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ sub CreateVideoPlayerView()
m.view.observeField("selectPlaybackInfoPressed", "onSelectPlaybackInfoPressed")
m.view.observeField("selectSubtitlePressed", "onSelectSubtitlePressed")
m.view.observeField("selectAudioPressed", "onSelectAudioPressed")
m.view.observeField("selectSpeedPressed", "onSelectSpeedPressed")

mediaSourceId = m.global.queueManager.callFunc("getCurrentItem").mediaSourceId

Expand Down Expand Up @@ -119,6 +120,37 @@ sub onSelectAudioPressed()
m.global.sceneManager.observeField("returnData", "onSelectionMade")
end sub

' onSelectSpeedPressed: Display audio selection dialog
'
sub onSelectSpeedPressed()

speedData = {
data: []
}

speeds = [0.5, 0.75, 1, 1.5, 2, 2.5, 3]
index = 0
for each speed in speeds
speedItem = {
"Index": index,
"Speed": speed,
"IsExternal": false,
"Type": "speedselection",
"Track": {
"description": speed
}
}
index++
if speed = m.global.sceneManager.currentSpeed
speedItem.selected = true
end if
speedData.data.push(speedItem)
end for

m.global.sceneManager.callFunc("radioDialog", tr("Select Speed"), speedData)
m.global.sceneManager.observeField("returnData", "onSelectionMade")
end sub

' User requested subtitle selection popup
sub onSelectSubtitlePressed()
subtitleData = {
Expand Down Expand Up @@ -188,6 +220,11 @@ sub onSelectionMade()
processAudioSelection()
return
end if

if LCase(m.global.sceneManager.returnData.type) = "speedselection"
processSpeedSelection()
return
end if
end sub


Expand All @@ -212,6 +249,15 @@ sub processAudioSelection()
m.view.audioIndex = selectedAudioTrack.index
end sub

' processSpeedSelection: Speed selection handler
'
sub processSpeedSelection()
selectedSpeed = m.global.sceneManager.returnData

m.global.sceneManager.currentSpeed = selectedSpeed.speed
m.view.selectedSpeed = selectedSpeed.speed
end sub

sub processSubtitleSelection()
m.selectedSubtitle = m.global.sceneManager.returnData

Expand Down
1 change: 1 addition & 0 deletions components/video/OSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<IconButton id="chapterList" padding="16" icon="pkg:/images/icons/numberList.png" height="65" width="100" />
<IconButton id="showSubtitleMenu" padding="0" icon="pkg:/images/icons/subtitle.png" height="65" width="100" />
<IconButton id="showAudioMenu" padding="27" icon="pkg:/images/icons/musicNote.png" height="65" width="100" />
<IconButton id="showSpeedMenu" padding="27" icon="pkg:/images/icons/speedMenu.png" height="65" width="100" />
</ButtonGroup>

<ButtonGroup id="videoControls" itemSpacings="[20]" layoutDirection="horiz" horizAlignment="center" translation="[960,875]">
Expand Down
23 changes: 23 additions & 0 deletions components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sub init()
m.top.id = currentItem.id

m.top.seekMode = "accurate"
m.top.playbackSpeed = m.global.sceneManager.currentSpeed

m.playbackEnum = {
null: -10
Expand Down Expand Up @@ -71,6 +72,7 @@ sub init()
m.top.observeField("content", "onContentChange")
m.top.observeField("selectedSubtitle", "onSubtitleChange")
m.top.observeField("audioIndex", "onAudioIndexChange")
m.top.observeField("selectedSpeed", "onSelectedSpeedChange")

' Get sibling data and pass to OSD
setSiblingData()
Expand Down Expand Up @@ -303,6 +305,12 @@ sub handleShowAudioMenuAction()
m.top.selectAudioPressed = true
end sub

' handleShowSpeedMenuAction: Handles action to show speed selection menu
'
sub handleShowSpeedMenuAction()
m.top.selectSpeedPressed = true
end sub

' handleShowVideoInfoPopupAction: Handles action to show video info popup
'
sub handleShowVideoInfoPopupAction()
Expand Down Expand Up @@ -369,6 +377,11 @@ sub onOSDAction()
return
end if

if action = "showspeedmenu"
handleShowSpeedMenuAction()
return
end if

if action = "showvideoinfopopup"
handleShowVideoInfoPopupAction()
return
Expand Down Expand Up @@ -470,6 +483,16 @@ sub onAudioIndexChange()
m.LoadMetaDataTask.control = TaskControl.RUN
end sub

' Event handler for when selectedSpeed changes
sub onSelectedSpeedChange()
m.top.playbackSpeed = m.top.selectedSpeed
' you need to pause and resume video to have speed change take effect
if m.top.state = "playing"
m.top.control = VideoControl.PAUSE
m.top.control = VideoControl.RESUME
end if
end sub

sub onPlaybackErrorDialogClosed(msg)
sourceNode = msg.getRoSGNode()
sourceNode.unobserveField("buttonSelected")
Expand Down
2 changes: 2 additions & 0 deletions components/video/VideoPlayerView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
<field id="backPressed" type="boolean" alwaysNotify="true" />
<field id="selectSubtitlePressed" type="boolean" alwaysNotify="true" />
<field id="selectAudioPressed" type="boolean" alwaysNotify="true" />
<field id="selectSpeedPressed" type="boolean" alwaysNotify="true" />
<field id="selectPlaybackInfoPressed" type="boolean" alwaysNotify="true" />
<field id="PlaySessionId" type="string" />
<field id="Subtitles" type="array" />
<field id="SelectedSubtitle" type="integer" value="-2" alwaysNotify="true" />
<field id="previousSubtitleWasEncoded" type="boolean" />
<field id="selectedSpeed" type="float" />
<field id="container" type="string" />
<field id="directPlaySupported" type="boolean" />
<field id="systemOverlay" type="boolean" value="false" />
Expand Down
Binary file added images/icons/speedMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.