|
542 | 542 | m.top.showID = videoContent[0].showID |
543 | 543 | m.top.cachedPlaybackInfo = videoContent[0].playbackInfo |
544 | 544 | m.top.doviDirectPlayFallbackAvailable = isValid(videoContent[0].doviDirectPlayFallbackAvailable) and videoContent[0].doviDirectPlayFallbackAvailable |
| 545 | + m.top.transcodeAvailable = isValid(videoContent[0].transcodeAvailable) and videoContent[0].transcodeAvailable |
545 | 546 |
|
546 | | - ' Reset bypass flag so subsequent reloads (audio/subtitle changes) re-evaluate DoVi naturally. |
547 | | - ' It will be set back to true by the error handler if another buffer overflow occurs. |
| 547 | + ' Reset retry flags so subsequent reloads (audio/subtitle changes) use fresh evaluation. |
548 | 548 | m.LoadMetaDataTask.bypassDoviPreservation = false |
| 549 | + m.LoadMetaDataTask.forceTranscoding = false |
549 | 550 |
|
550 | 551 | if isValidAndNotEmpty(videoContent[0].json) |
551 | 552 | m.osd.json = formatJson(videoContent[0].json) |
|
879 | 880 | end if |
880 | 881 | end sub |
881 | 882 |
|
| 883 | +' retryPlayback: Re-runs the content loader from the current position with updated task flags. |
| 884 | +' Used by error handlers to retry without exiting the player. |
| 885 | +' @param {boolean} bypassDovi - skips DoVi container profile so the server can grant direct play |
| 886 | +' @param {boolean} forceTranscode - disables direct play so the server returns a transcode URL |
| 887 | +sub retryPlayback(bypassDovi as boolean, forceTranscode as boolean) |
| 888 | + m.global.queueManager.callFunc("setTopStartingPoint", int(m.top.position) * 10000000&) |
| 889 | + ' Prevents ViewCreator popping the scene when stop causes Roku to fire "finished". |
| 890 | + m.top.isRetrying = true |
| 891 | + m.top.control = "stop" |
| 892 | + m.LoadMetaDataTask.bypassDoviPreservation = bypassDovi |
| 893 | + m.LoadMetaDataTask.forceTranscoding = forceTranscode |
| 894 | + m.LoadMetaDataTask.selectedSubtitleIndex = m.top.SelectedSubtitle |
| 895 | + m.LoadMetaDataTask.selectedAudioStreamIndex = m.top.audioIndex |
| 896 | + m.LoadMetaDataTask.itemId = m.currentItem.id |
| 897 | + m.LoadMetaDataTask.observeField("content", "onVideoContentLoaded") |
| 898 | + m.LoadMetaDataTask.control = "RUN" |
| 899 | +end sub |
| 900 | + |
882 | 901 | ' |
883 | 902 | ' When Video Player state changes |
884 | 903 | sub onState() |
|
909 | 928 | if isBufferLoopError and m.top.doviDirectPlayFallbackAvailable |
910 | 929 | m.log.warn("Buffer overflow in DoVi transcode; falling back to direct play", m.currentItem.id) |
911 | 930 | m.top.doviDirectPlayFallbackAvailable = false ' prevent retry loop if direct play also fails |
912 | | - m.global.queueManager.callFunc("setTopStartingPoint", int(m.top.position) * 10000000&) |
913 | | - ' Prevents ViewCreator popping the scene when stop causes Roku to fire "finished". |
914 | | - m.top.isRetrying = true |
915 | | - m.top.control = "stop" |
916 | | - m.LoadMetaDataTask.bypassDoviPreservation = true |
917 | | - m.LoadMetaDataTask.selectedSubtitleIndex = m.top.SelectedSubtitle |
918 | | - m.LoadMetaDataTask.selectedAudioStreamIndex = m.top.audioIndex |
919 | | - m.LoadMetaDataTask.itemId = m.currentItem.id |
920 | | - m.LoadMetaDataTask.observeField("content", "onVideoContentLoaded") |
921 | | - m.LoadMetaDataTask.control = "RUN" |
| 931 | + retryPlayback(true, false) |
922 | 932 | else if not m.playReported and m.top.transcodeAvailable |
923 | | - m.log.info("retrying with transcoding", m.currentItem.id, m.top.SelectedSubtitle, m.top.audioIndex) |
924 | | - m.top.retryWithTranscoding = true ' If playback was not reported, retry with transcoding |
| 933 | + m.log.warn("Direct play failed; falling back to transcode", m.currentItem.id) |
| 934 | + m.top.transcodeAvailable = false ' prevent retry loop if transcode also fails |
| 935 | + retryPlayback(false, true) |
925 | 936 | else |
926 | 937 | ' If an error was encountered, stop timers and display dialog |
927 | 938 | m.top.unobserveField("state") |
|
0 commit comments