Skip to content

Commit

Permalink
Merge pull request #1965 from jellyfin/2.1.z
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Oct 6, 2024
2 parents bbc9974 + 41c870c commit 6756b01
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# If you want to get_images, you'll also need convert from ImageMagick
##########################################################################

VERSION := 2.1.5
VERSION := 2.1.6

## usage

Expand Down
8 changes: 7 additions & 1 deletion components/ItemGrid/GridItemSmall.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "pkg:/source/utils/config.bs"
sub init()
m.itemPoster = m.top.findNode("itemPoster")
m.posterText = m.top.findNode("posterText")
m.title = m.top.findNode("title")
initTitle()
m.posterText.font.size = 30
m.title.font.size = 25
m.backdrop = m.top.findNode("backdrop")
Expand All @@ -23,6 +23,10 @@ sub init()
end if
end sub

sub initTitle()
m.title = m.top.findNode("title")
end sub

sub itemContentChanged()
m.backdrop.blendColor = "#101010"

Expand Down Expand Up @@ -54,6 +58,8 @@ sub itemContentChanged()
end sub

sub focusChanged()
if not isValid(m.title) then initTitle()

if m.top.itemHasFocus = true
m.title.repeatCount = -1
else
Expand Down
30 changes: 24 additions & 6 deletions components/ItemGrid/LoadVideoContentTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "pkg:/source/utils/config.bs"
import "pkg:/source/api/Image.bs"
import "pkg:/source/api/userauth.bs"
import "pkg:/source/utils/deviceCapabilities.bs"
import "pkg:/source/utils/session.bs"

enum SubtitleSelection
notset = -2
Expand Down Expand Up @@ -71,14 +72,24 @@ end function
sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_stream_idx = 1 as integer, forceTranscoding = false as boolean)

meta = ItemMetaData(video.id)
subtitle_idx = m.top.selectedSubtitleIndex

if not isValid(meta)
video.errorMsg = "Error loading metadata"
video.content = invalid
return
end if

session.video.Update(meta)

if isValid(meta.json.MediaSources[0].RunTimeTicks)
if meta.json.MediaSources[0].RunTimeTicks = 0
video.length = 0
else
video.length = meta.json.MediaSources[0].RunTimeTicks / 10000000
end if
end if
video.MaxVideoDecodeResolution = [meta.json.MediaSources[0].MediaStreams[0].Width, meta.json.MediaSources[0].MediaStreams[0].Height]

subtitle_idx = m.top.selectedSubtitleIndex
videotype = LCase(meta.type)

' Check for any Live TV streams or Recordings coming from other places other than the TV Guide
Expand Down Expand Up @@ -183,6 +194,11 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
end if

video.container = getContainerType(meta)
if video.container = "mp4"
video.content.StreamFormat = "mp4"
else if video.container = "mkv"
video.content.StreamFormat = "mkv"
end if

if not isValid(m.playbackInfo.MediaSources[0])
m.playbackInfo = meta.json
Expand All @@ -197,12 +213,10 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
}
end if


' 'TODO: allow user selection of subtitle track before playback initiated, for now set to no subtitles
video.directPlaySupported = m.playbackInfo.MediaSources[0].SupportsDirectPlay
fully_external = false


' For h264/hevc video, Roku spec states that it supports specfic encoding levels
' The device can decode content with a Higher Encoding level but may play it back with certain
' artifacts. If the user preference is set, and the only reason the server says we need to
Expand Down Expand Up @@ -351,11 +365,15 @@ sub addVideoContentURL(video, mediaSourceId, audio_stream_idx, fully_external)
protocol = LCase(m.playbackInfo.MediaSources[0].Protocol)
if protocol <> "file"
uri = parseUrl(m.playbackInfo.MediaSources[0].Path)
if isLocalhost(uri[2])
if not isValidAndNotEmpty(uri) then return

if isValid(uri[2]) and isLocalhost(uri[2])
' if the domain of the URI is local to the server,
' create a new URI by appending the received path to the server URL
' later we will substitute the users provided URL for this case
video.content.url = buildURL(uri[4])
if isValid(uri[4])
video.content.url = buildURL(uri[4])
end if
else
fully_external = true
video.content.url = m.playbackInfo.MediaSources[0].Path
Expand Down
2 changes: 0 additions & 2 deletions components/ItemGrid/MusicArtistGridItem.bs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ sub init()
m.itemPoster.loadDisplayMode = m.topParent.imageDisplayMode
end if

m.gridTitles = m.global.session.user.settings["itemgrid.gridTitles"]
m.posterText.visible = false
m.postTextBackground.visible = false

end sub

sub itemContentChanged()
Expand Down
17 changes: 14 additions & 3 deletions components/captionTask.bs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "pkg:/source/utils/config.bs"
import "pkg:/source/api/baserequest.bs"
import "pkg:/source/roku_modules/log/LogMixin.brs"

sub init()
m.log = log.Logger("captionTask")
m.top.observeField("url", "fetchCaption")
m.top.currentCaption = []
m.top.currentPos = 0
Expand Down Expand Up @@ -41,17 +43,26 @@ sub setFont()
end sub

sub fetchCaption()
m.log.debug("start fetchCaption()")
m.captionTimer.control = "stop"
re = CreateObject("roRegex", "(http.*?\.vtt)", "s")
url = re.match(m.top.url)[0]

if url <> invalid
port = createObject("roMessagePort")
m.reader.setUrl(url)
text = m.reader.GetToString()
m.captionList = parseVTT(text)
m.captionTimer.control = "start"
m.reader.setMessagePort(port)
if m.reader.AsyncGetToString()
msg = port.waitMessage(0)
if type(msg) = "roUrlEvent"
m.captionList = parseVTT(msg.GetString())
m.captionTimer.control = "start"
end if
end if
else
m.captionTimer.control = "stop"
end if
m.log.debug("end fetchCaption()", url)
end sub

function newlabel(txt)
Expand Down
5 changes: 4 additions & 1 deletion components/data/PersonData.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import "pkg:/source/utils/config.bs"

sub setFields()
json = m.top.json
m.top.Type = "Person"

if json = invalid then return

m.top.id = json.id
m.top.favorite = json.UserData.isFavorite
m.top.Type = "Person"
setPoster()
end sub

Expand Down
21 changes: 17 additions & 4 deletions components/home/HomeItem.bs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ sub init()
initItemPoster()
m.itemProgress = m.top.findNode("progress")
m.itemProgressBackground = m.top.findNode("progressBackground")
m.itemIcon = m.top.findNode("itemIcon")
initItemIcon()
initItemTextExtra()
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
m.unplayedCount = m.top.findNode("unplayedCount")
m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount")
m.playedIndicator = m.top.findNode("playedIndicator")
initPlayedIndicator()

m.showProgressBarAnimation = m.top.findNode("showProgressBar")
m.showProgressBarField = m.top.findNode("showProgressBarField")
Expand Down Expand Up @@ -50,6 +50,14 @@ sub initBackdrop()
m.backdrop = m.top.findNode("backdrop")
end sub

sub initItemIcon()
m.itemIcon = m.top.findNode("itemIcon")
end sub

sub initPlayedIndicator()
m.playedIndicator = m.top.findNode("playedIndicator")
end sub

sub itemContentChanged()
if isValid(m.unplayedCount) then m.unplayedCount.visible = false
itemData = m.top.itemContent
Expand All @@ -63,6 +71,8 @@ sub itemContentChanged()
if not isValid(m.itemText) then initItemText()
if not isValid(m.itemTextExtra) then initItemTextExtra()
if not isValid(m.backdrop) then initBackdrop()
if not isValid(m.itemIcon) then initItemIcon()
if not isValid(m.playedIndicator) then initPlayedIndicator()

m.itemPoster.width = itemData.imageWidth
m.itemText.maxWidth = itemData.imageWidth
Expand All @@ -83,11 +93,14 @@ sub itemContentChanged()

if LCase(itemData.type) = "series"
if isValid(localGlobal) and isValid(localGlobal.session) and isValid(localGlobal.session.user) and isValid(localGlobal.session.user.settings)
if not localGlobal.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"]
unwatchedEpisodeCountSetting = localGlobal.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"]
if isValid(unwatchedEpisodeCountSetting) and not unwatchedEpisodeCountSetting
if isValid(itemData.json.UserData) and isValid(itemData.json.UserData.UnplayedItemCount)
if itemData.json.UserData.UnplayedItemCount > 0
if isValid(m.unplayedCount) then m.unplayedCount.visible = true
m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount
if isValid(m.unplayedEpisodeCount)
m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount
end if
end if
end if
end if
Expand Down
6 changes: 4 additions & 2 deletions components/tvshows/TVShowDetails.bs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ end function

sub onShuffleEpisodeDataLoaded()
m.getShuffleEpisodesTask.unobserveField("data")
m.global.queueManager.callFunc("set", m.getShuffleEpisodesTask.data.items)
m.global.queueManager.callFunc("playQueue")
if isValid(m.getShuffleEpisodesTask.data)
m.global.queueManager.callFunc("set", m.getShuffleEpisodesTask.data.items)
m.global.queueManager.callFunc("playQueue")
end if
end sub

function onKeyEvent(key as string, press as boolean) as boolean
Expand Down
21 changes: 11 additions & 10 deletions components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "pkg:/source/utils/misc.bs"
import "pkg:/source/utils/config.bs"
import "pkg:/source/utils/session.bs"
import "pkg:/source/roku_modules/log/LogMixin.brs"

sub init()
Expand Down Expand Up @@ -102,6 +103,7 @@ sub handleItemSkipAction(action as string)
' If there is something next in the queue, play it
if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1
m.top.control = "stop"
session.video.Delete()
m.global.sceneManager.callFunc("clearPreviousScene")
m.global.queueManager.callFunc("moveForward")
m.global.queueManager.callFunc("playQueue")
Expand All @@ -114,6 +116,7 @@ sub handleItemSkipAction(action as string)
' If there is something previous in the queue, play it
if m.global.queueManager.callFunc("getPosition") > 0
m.top.control = "stop"
session.video.Delete()
m.global.sceneManager.callFunc("clearPreviousScene")
m.global.queueManager.callFunc("moveBack")
m.global.queueManager.callFunc("playQueue")
Expand Down Expand Up @@ -612,19 +615,12 @@ sub onState(msg)
' Pass video state into OSD
m.osd.playbackState = m.top.state

' When buffering, start timer to monitor buffering process
if m.top.state = "buffering"
' start buffer timer
' When buffering, start timer to monitor buffering process
if isValid(m.bufferCheckTimer)
m.bufferCheckTimer.control = "start"
m.bufferCheckTimer.ObserveField("fire", "bufferCheck")
end if

' update server if needed
if not m.playReported
m.playReported = true
ReportPlayback("start")
end if
else if m.top.state = "error"
m.log.error(m.top.errorCode, m.top.errorMsg, m.top.errorStr, m.top.errorCode)

Expand All @@ -635,10 +631,10 @@ sub onState(msg)
else
' If an error was encountered, Display dialog
showPlaybackErrorDialog(tr("Error During Playback"))
session.video.Delete()
end if

' Stop playback and exit player
m.top.control = "stop"

else if m.top.state = "playing"

' Check if next episode is available
Expand All @@ -664,9 +660,11 @@ sub onState(msg)
m.playbackTimer.control = "stop"
ReportPlayback("stop")
m.playReported = false
session.video.Delete()
else if m.top.state = "finished"
m.playbackTimer.control = "stop"
ReportPlayback("finished")
session.video.Delete()
else
m.log.warning("Unhandled state", m.top.state, m.playReported, m.playFinished)
end if
Expand Down Expand Up @@ -725,6 +723,7 @@ sub bufferCheck(msg)

' Stop playback and exit player
m.top.control = "stop"
session.video.Delete()
end if
end if

Expand Down Expand Up @@ -794,6 +793,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
if key = "OK" and m.nextEpisodeButton.hasfocus() and not m.top.trickPlayBar.visible
m.top.control = "stop"
m.top.state = "finished"
session.video.Delete()
hideNextEpisodeButton()
return true
else
Expand Down Expand Up @@ -868,6 +868,7 @@ function onKeyEvent(key as string, press as boolean) as boolean

if key = "back"
m.top.control = "stop"
session.video.Delete()
end if

return false
Expand Down
2 changes: 1 addition & 1 deletion manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title=Jellyfin
major_version=2
minor_version=1
build_version=5
build_version=6

### Main Menu Icons / Channel Poster Artwork

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jellyfin-roku",
"type": "module",
"version": "2.1.5",
"version": "2.1.6",
"description": "Roku app for Jellyfin media server",
"dependencies": {
"@rokucommunity/bslib": "0.1.1",
Expand Down
Loading

0 comments on commit 6756b01

Please sign in to comment.