simpler spinner

This commit is contained in:
sevenrats 2023-02-04 00:26:55 -05:00
parent fef110058a
commit 3b00d3ab28
7 changed files with 26 additions and 24 deletions

View File

@ -245,14 +245,6 @@ sub userMessage(title as string, message as string)
m.scene.dialog = dialog m.scene.dialog = dialog
end sub end sub
'
' Display Dialog to show user app is fetching server data
sub progressDialog(title as string)
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = title
m.scene.dialog = dialog
end sub
' '
' Close currently displayed dialog ' Close currently displayed dialog
sub dismiss_dialog() sub dismiss_dialog()

View File

@ -9,8 +9,6 @@
<function name="clearPreviousScene" /> <function name="clearPreviousScene" />
<function name="resetTime" /> <function name="resetTime" />
<function name="userMessage" /> <function name="userMessage" />
<function name="progressDialog" />
<function name="dismiss_dialog" />
<field id="currentUser" type="string" onChange="updateUser" /> <field id="currentUser" type="string" onChange="updateUser" />
</interface> </interface>
<script type="text/brightscript" uri="SceneManager.brs" /> <script type="text/brightscript" uri="SceneManager.brs" />

View File

@ -19,13 +19,10 @@ sub init()
m.buttonGrp.setFocus(true) m.buttonGrp.setFocus(true)
m.top.lastFocus = m.buttonGrp m.top.lastFocus = m.buttonGrp
m.spinner = m.top.findNode("spinner")
m.trailerButton = m.top.findNode("trailer-button") m.trailerButton = m.top.findNode("trailer-button")
m.trailerButton.text = tr("Play Trailer") m.trailerButton.text = tr("Play Trailer")
m.top.observeField("itemContent", "itemContentChanged") m.top.observeField("itemContent", "itemContentChanged")
m.top.findNode("communityRatingGroup").visible = false
end sub end sub
sub OnScreenShown() sub OnScreenShown()

View File

@ -8,7 +8,7 @@
<Label id="releaseYear" /> <Label id="releaseYear" />
<Label id="runtime" /> <Label id="runtime" />
<Label id="officialRating" /> <Label id="officialRating" />
<LayoutGroup id="communityRatingGroup" layoutDirection="horiz" itemSpacings="[-5]"> <LayoutGroup id="communityRatingGroup" layoutDirection="horiz" itemSpacings="[-5]" visible="false">
<Poster id="star" uri="pkg:/images/sharp_star_white_18dp.png" height="32" width="32" blendColor="#cb272a" visible="false"/> <Poster id="star" uri="pkg:/images/sharp_star_white_18dp.png" height="32" width="32" blendColor="#cb272a" visible="false"/>
<Label id="communityRating" /> <Label id="communityRating" />
</LayoutGroup> </LayoutGroup>

View File

@ -119,10 +119,8 @@ sub Main (args as dynamic) as void
if itemNode = invalid or itemNode.id = "" then return if itemNode = invalid or itemNode.id = "" then return
if itemNode.type = "Episode" or itemNode.type = "Movie" or itemNode.type = "Video" if itemNode.type = "Episode" or itemNode.type = "Movie" or itemNode.type = "Video"
if itemNode.type = "Episode" and itemNode.selectedAudioStreamIndex <> invalid and itemNode.selectedAudioStreamIndex > 1 if itemNode.type = "Episode" and itemNode.selectedAudioStreamIndex <> invalid and itemNode.selectedAudioStreamIndex > 1
m.global.sceneManager.callFunc("progressDialog", tr("Loading Episode Options"))
video = CreateVideoPlayerGroup(itemNode.id, invalid, itemNode.selectedAudioStreamIndex) video = CreateVideoPlayerGroup(itemNode.id, invalid, itemNode.selectedAudioStreamIndex)
else else
m.global.sceneManager.callFunc("progressDialog", tr("Loading Video Options"))
video = CreateVideoPlayerGroup(itemNode.id) video = CreateVideoPlayerGroup(itemNode.id)
end if end if
if video <> invalid and video.errorMsg <> "introaborted" if video <> invalid and video.errorMsg <> "introaborted"
@ -167,7 +165,6 @@ sub Main (args as dynamic) as void
group = CreateItemGrid(selectedItem) group = CreateItemGrid(selectedItem)
sceneManager.callFunc("pushScene", group) sceneManager.callFunc("pushScene", group)
else if selectedItem.type = "Episode" else if selectedItem.type = "Episode"
m.global.sceneManager.callFunc("progressDialog", tr("Loading Episode Options"))
' play episode ' play episode
' todo: create an episode page to link here ' todo: create an episode page to link here
video_id = selectedItem.id video_id = selectedItem.id
@ -238,7 +235,6 @@ sub Main (args as dynamic) as void
node = getMsgPicker(msg, "picker") node = getMsgPicker(msg, "picker")
group = CreateMovieDetailsGroup(node) group = CreateMovieDetailsGroup(node)
else if isNodeEvent(msg, "seriesSelected") else if isNodeEvent(msg, "seriesSelected")
m.global.sceneManager.callFunc("progressDialog", tr("Loading Seriers Options"))
' If you select a TV Series from ANYWHERE, follow this flow ' If you select a TV Series from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker") node = getMsgPicker(msg, "picker")
group = CreateSeriesDetailsGroup(node) group = CreateSeriesDetailsGroup(node)
@ -320,7 +316,6 @@ sub Main (args as dynamic) as void
else if isNodeEvent(msg, "episodeSelected") else if isNodeEvent(msg, "episodeSelected")
' If you select a TV Episode from ANYWHERE, follow this flow ' If you select a TV Episode from ANYWHERE, follow this flow
m.selectedItemType = "Episode" m.selectedItemType = "Episode"
m.global.sceneManager.callFunc("progressDialog", tr("Loading Episode Options"))
node = getMsgPicker(msg, "picker") node = getMsgPicker(msg, "picker")
video_id = node.id video_id = node.id
if node.selectedAudioStreamIndex <> invalid and node.selectedAudioStreamIndex > 1 if node.selectedAudioStreamIndex <> invalid and node.selectedAudioStreamIndex > 1
@ -369,7 +364,6 @@ sub Main (args as dynamic) as void
group = CreateVideoPlayerGroup(node.id) group = CreateVideoPlayerGroup(node.id)
sceneManager.callFunc("pushScene", group) sceneManager.callFunc("pushScene", group)
else if node.type = "Episode" else if node.type = "Episode"
m.global.sceneManager.callFunc("progressDialog", tr("Loading Episode Options"))
group = CreateVideoPlayerGroup(node.id) group = CreateVideoPlayerGroup(node.id)
sceneManager.callFunc("pushScene", group) sceneManager.callFunc("pushScene", group)
else if node.type = "Audio" else if node.type = "Audio"
@ -387,7 +381,6 @@ sub Main (args as dynamic) as void
btn = getButton(msg) btn = getButton(msg)
group = sceneManager.callFunc("getActiveScene") group = sceneManager.callFunc("getActiveScene")
if btn <> invalid and btn.id = "play-button" if btn <> invalid and btn.id = "play-button"
m.global.sceneManager.callFunc("progressDialog", tr("Loading Movie Options"))
' Check if a specific Audio Stream was selected ' Check if a specific Audio Stream was selected
audio_stream_idx = 1 audio_stream_idx = 1

View File

@ -2,13 +2,16 @@ function VideoPlayer(id, mediaSourceId = invalid, audio_stream_idx = 1, subtitle
' Get video controls and UI ' Get video controls and UI
video = CreateObject("roSGNode", "JFVideo") video = CreateObject("roSGNode", "JFVideo")
video.id = id video.id = id
startMediaLoadingSpinner()
AddVideoContent(video, mediaSourceId, audio_stream_idx, subtitle_idx, -1, forceTranscoding, showIntro, allowResumeDialog) AddVideoContent(video, mediaSourceId, audio_stream_idx, subtitle_idx, -1, forceTranscoding, showIntro, allowResumeDialog)
if video.errorMsg = "introaborted" if video.errorMsg = "introaborted"
stopMediaLoadingSpinner()
return video return video
end if end if
if video.content = invalid if video.content = invalid
stopMediaLoadingSpinner()
return invalid return invalid
end if end if
jellyfin_blue = "#00a4dcFF" jellyfin_blue = "#00a4dcFF"
@ -16,6 +19,7 @@ function VideoPlayer(id, mediaSourceId = invalid, audio_stream_idx = 1, subtitle
video.retrievingBar.filledBarBlendColor = jellyfin_blue video.retrievingBar.filledBarBlendColor = jellyfin_blue
video.bufferingBar.filledBarBlendColor = jellyfin_blue video.bufferingBar.filledBarBlendColor = jellyfin_blue
video.trickPlayBar.filledBarBlendColor = jellyfin_blue video.trickPlayBar.filledBarBlendColor = jellyfin_blue
stopMediaLoadingSpinner()
return video return video
end function end function
@ -57,7 +61,9 @@ sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -
playbackPosition = meta.json.UserData.PlaybackPositionTicks playbackPosition = meta.json.UserData.PlaybackPositionTicks
if allowResumeDialog if allowResumeDialog
if playbackPosition > 0 if playbackPosition > 0
stopMediaLoadingSpinner()
dialogResult = startPlayBackOver(playbackPosition) dialogResult = startPlayBackOver(playbackPosition)
startMediaLoadingSpinner()
'Dialog returns -1 when back pressed, 0 for resume, and 1 for start over 'Dialog returns -1 when back pressed, 0 for resume, and 1 for start over
if dialogResult = -1 if dialogResult = -1
'User pressed back, return invalid and don't load video 'User pressed back, return invalid and don't load video
@ -311,7 +317,6 @@ sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -
if not fully_external if not fully_external
video.content = authorize_request(video.content) video.content = authorize_request(video.content)
end if end if
m.global.sceneManager.callFunc("dismiss_dialog")
end sub end sub
function PlayIntroVideo(video_id, audio_stream_idx) as boolean function PlayIntroVideo(video_id, audio_stream_idx) as boolean
@ -368,8 +373,6 @@ end function
'Opens dialog asking user if they want to resume video or start playback over only on the home screen 'Opens dialog asking user if they want to resume video or start playback over only on the home screen
function startPlayBackOver(time as longinteger) as integer function startPlayBackOver(time as longinteger) as integer
'Closes Loading Dialog
m.global.sceneManager.callFunc("dismiss_dialog")
if m.scene.focusedChild.focusedChild.overhangTitle = tr("Home") and (m.videotype = "Episode" or m.videotype = "Series") if m.scene.focusedChild.focusedChild.overhangTitle = tr("Home") and (m.videotype = "Episode" or m.videotype = "Series")
return option_dialog([tr("Resume playing at ") + ticksToHuman(time) + ".", tr("Start over from the beginning."), tr("Watched"), tr("Go to series"), tr("Go to season"), tr("Go to episode")]) return option_dialog([tr("Resume playing at ") + ticksToHuman(time) + ".", tr("Start over from the beginning."), tr("Watched"), tr("Go to series"), tr("Go to season"), tr("Go to episode")])
else else

View File

@ -281,3 +281,22 @@ function findNodeBySubtype(node, subtype)
return foundNodes return foundNodes
end function end function
sub startMediaLoadingSpinner()
m.spinner = createObject("roSGNode", "Spinner")
m.spinner.translation = "[900, 450]"
m.scene.appendChild(m.spinner)
dialog = createObject("roSGNode", "ProgressDialog")
dialog.id = "invisibiledialog"
dialog.visible = false
m.scene.dialog = dialog
end sub
sub stopMediaLoadingSpinner()
if isValid(m.spinner)
m.spinner.visible = false
end if
if isValid(m.scene.dialog)
m.scene.dialog.close = true
end if
end sub