Skip to content

Commit

Permalink
Merge pull request #1942 from jellyfin/215-merge-conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Sep 29, 2024
2 parents 7b581ad + 8ea8bdd commit 4f1f333
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 25 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.4
VERSION := 2.1.5

## usage

Expand Down
6 changes: 3 additions & 3 deletions components/ItemGrid/GridItem.bs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ sub init()
m.checkmark.width = 90
m.checkmark.height = 60

m.itemText.translation = [0, m.itemPoster.height + 7]
m.itemText.visible = m.gridTitles = "showalways"

' Add some padding space when Item Titles are always showing
if m.itemText.visible then m.itemText.maxWidth = 250

Expand All @@ -38,6 +35,9 @@ sub init()
end if
end if

m.itemText.translation = [0, m.itemPoster.height + 7]
m.itemText.visible = m.gridTitles = "showalways"

end sub

sub itemContentChanged()
Expand Down
42 changes: 37 additions & 5 deletions components/ItemGrid/ItemGrid.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "pkg:/source/roku_modules/log/LogMixin.brs"

sub init()
m.log = log.Logger("ItemGrid")
m.log.debug("start init()")
m.options = m.top.findNode("options")

m.showItemCount = m.global.session.user.settings["itemgrid.showItemCount"]
Expand Down Expand Up @@ -70,6 +71,7 @@ sub init()
m.resetGrid = m.global.session.user.settings["itemgrid.reset"]

m.top.gridTitles = m.global.session.user.settings["itemgrid.gridTitles"]
m.log.debug("end init()")
end sub

'Genre Item Selected
Expand All @@ -79,6 +81,7 @@ end sub

'Load initial set of Data
sub loadInitialItems()
m.log.debug("start loadInitialItems()")
m.loadItemsTask.control = "stop"
startLoadingSpinner()

Expand Down Expand Up @@ -235,6 +238,7 @@ sub loadInitialItems()
startLoadingSpinner(false)
m.loadItemsTask.control = "RUN"
SetUpOptions()
m.log.debug("end loadInitialItems()")
end sub

' Set Movies view, sort, and filter options
Expand Down Expand Up @@ -445,6 +449,7 @@ end sub

'Handle loaded data, and add to Grid
sub ItemDataLoaded(msg)
m.log.debug("start ItemDataLoaded()")
itemData = msg.GetData()
m.loadItemsTask.unobserveField("content")
m.loadItemsTask.content = []
Expand Down Expand Up @@ -501,22 +506,28 @@ sub ItemDataLoaded(msg)
end if

stopLoadingSpinner()
m.log.debug("end ItemDataLoaded()")
end sub

'Set Background Image
sub SetBackground(backgroundUri as string)

m.log.debug("start SetBackground()", backgroundUri, m.swapAnimation.state, m.newBackdrop.loadStatus)
'If a new image is being loaded, or transitioned to, store URL to load next
if m.swapAnimation.state <> "stopped" or m.newBackdrop.loadStatus = "loading"
m.queuedBGUri = backgroundUri
return
if not m.top.alphaActive
if m.swapAnimation.state <> "stopped" or m.newBackdrop.loadStatus = "loading"
m.log.debug("caching new background URI")
m.queuedBGUri = backgroundUri
return
end if
end if

m.newBackdrop.uri = backgroundUri
m.log.debug("end SetBackground()")
end sub

'Handle new item being focused
sub onItemFocused()
m.log.debug("start onItemFocused()", m.itemGrid.currFocusRow, m.itemGrid.itemFocused)

focusedRow = m.itemGrid.currFocusRow

Expand All @@ -525,7 +536,7 @@ sub onItemFocused()
updateTitle()

' If no selected item, set background to parent backdrop
if itemInt = -1
if itemInt = -1 or focusedRow = -1
return
end if

Expand All @@ -538,6 +549,7 @@ sub onItemFocused()
if focusedRow >= m.loadedRows - 5 and m.loadeditems < m.loadItemsTask.totalRecordCount
loadMoreData()
end if
m.log.debug("end onItemFocused()")
end sub

'When Image Loading Status changes
Expand All @@ -558,6 +570,7 @@ sub swapDone()

'If there is another one to load
if m.newBackdrop.uri <> m.queuedBGUri and m.queuedBGUri <> ""
m.log.debug("Loading queued backdrop image", m.queuedBGUri)
SetBackground(m.queuedBGUri)
m.queuedBGUri = ""
end if
Expand All @@ -566,13 +579,15 @@ end sub

'Load next set of items
sub loadMoreData()
m.log.debug("start loadMoreData()")
if m.Loading = true then return

startLoadingSpinner(false)
m.Loading = true
m.loadItemsTask.startIndex = m.loadedItems
m.loadItemsTask.observeField("content", "ItemDataLoaded")
m.loadItemsTask.control = "RUN"
m.log.debug("end loadMoreData()")
end sub

'Item Selected
Expand Down Expand Up @@ -767,6 +782,20 @@ function getItemFocused()
return invalid
end function

sub alphaActiveChanged()
m.log.debug("start alphaActiveChanged()", m.top.alphaActive)

if m.top.alphaActive
' fade into an empty backdrop
m.swapAnimation.state = "stop"
m.queuedBGUri = ""
' use a 1px image because we can't use the animation to fade into a blank uri string
SetBackground("pkg:/images/1px-262626.png")
end if

m.log.debug("end alphaActiveChanged()")
end sub

function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false

Expand Down Expand Up @@ -833,11 +862,14 @@ function onKeyEvent(key as string, press as boolean) as boolean
return true
end if
else if key = "left" and topGrp.isinFocusChain() and m.alpha.visible
m.log.debug("Now entering alpha menu")
m.top.alphaActive = true
topGrp.setFocus(false)
m.alphaMenu.setFocus(true)

return true
else if key = "right" and m.alpha.isinFocusChain()
m.log.debug("Now leaving alpha menu")
m.top.alphaActive = false
m.alphaMenu.setFocus(false)
topGrp.setFocus(true)
Expand Down
2 changes: 1 addition & 1 deletion components/ItemGrid/ItemGrid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<field id="quickPlayNode" type="node" alwaysNotify="true" />
<field id="imageDisplayMode" type="string" value="scaleToZoom" />
<field id="alphaSelected" type="string" alias="alpha.letterSelected" alwaysNotify="true" onChange="alphaSelectedChanged" />
<field id="alphaActive" type="boolean" value="false" />
<field id="alphaActive" type="boolean" value="false" onChange="alphaActiveChanged" />
<field id="jumpToItem" type="integer" value="" />
<field id="gridTitles" type="string" />
</interface>
Expand Down
2 changes: 1 addition & 1 deletion components/PlaystateTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ end sub
sub PlaystateUpdate()
if m.top.status = "start"
url = "Sessions/Playing"
else if m.top.status = "stop"
else if m.top.status = "stop" or m.top.status = "finished"
url = "Sessions/Playing/Stopped"
else if m.top.status = "update"
url = "Sessions/Playing/Progress"
Expand Down
1 change: 1 addition & 0 deletions components/data/ChannelData.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="ChannelData" extends="JFContentItem">
<interface>
<field id="image" type="node" onChange="setPoster" />
<field id="channelID" type="string" />
<field id="selectedAudioStreamIndex" type="integer" value="0" />
</interface>
Expand Down
36 changes: 28 additions & 8 deletions components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "pkg:/source/utils/misc.bs"
import "pkg:/source/utils/config.bs"
import "pkg:/source/roku_modules/log/LogMixin.brs"

sub init()
m.log = log.Logger("VideoPlayerView")
' Hide the overhang on init to prevent showing 2 clocks
m.top.getScene().findNode("overhang").visible = false
m.currentItem = m.global.queueManager.callFunc("getCurrentItem")
Expand Down Expand Up @@ -602,6 +604,7 @@ end sub
'
' When Video Player state changes
sub onState(msg)
m.log.debug("start onState()", m.top.state)
if isValid(m.captionTask)
m.captionTask.playerState = m.top.state + m.top.globalCaptionMode
end if
Expand All @@ -610,12 +613,23 @@ sub onState(msg)
m.osd.playbackState = m.top.state

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

' start timer
m.bufferCheckTimer.control = "start"
m.bufferCheckTimer.ObserveField("fire", "bufferCheck")
' 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)

print m.top.errorInfo

if not m.playReported and m.top.transcodeAvailable
m.top.retryWithTranscoding = true ' If playback was not reported, retry with transcoding
else
Expand All @@ -625,7 +639,6 @@ sub onState(msg)

' Stop playback and exit player
m.top.control = "stop"
m.top.backPressed = true
else if m.top.state = "playing"

' Check if next episode is available
Expand All @@ -651,16 +664,22 @@ sub onState(msg)
m.playbackTimer.control = "stop"
ReportPlayback("stop")
m.playReported = false
else if m.top.state = "finished"
m.playbackTimer.control = "stop"
ReportPlayback("finished")
else
m.log.warning("Unhandled state", m.top.state, m.playReported, m.playFinished)
end if

m.log.debug("end onState()", m.top.state)
end sub

'
' Report playback to server
sub ReportPlayback(state = "update" as string)

if m.top.position = invalid then return

m.log.debug("start ReportPlayback()", state, int(m.top.position))

params = {
"ItemId": m.top.id,
"PlaySessionId": m.top.PlaySessionId,
Expand All @@ -679,6 +698,8 @@ sub ReportPlayback(state = "update" as string)
playstateTask = m.global.playstateTask
playstateTask.setFields({ status: state, params: params })
playstateTask.control = "RUN"

m.log.debug("end ReportPlayback()", state, int(m.top.position))
end sub

'
Expand All @@ -704,7 +725,6 @@ sub bufferCheck(msg)

' Stop playback and exit player
m.top.control = "stop"
m.top.backPressed = true
end if
end if

Expand Down
Binary file added images/1px-262626.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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=4
build_version=5

### 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.4",
"version": "2.1.5",
"description": "Roku app for Jellyfin media server",
"dependencies": {
"@rokucommunity/bslib": "0.1.1",
Expand Down
12 changes: 11 additions & 1 deletion source/api/Items.bs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioT
"SubtitleStreamIndex": subtitleTrackIndex
}

if mediaSourceId <> "" then params.MediaSourceId = mediaSourceId
' Note: Jellyfin v10.9+ now remuxs LiveTV and does not allow DirectPlay anymore.
' Because of this, we need to tell the server "EnableDirectPlay = false" so that we receive the
' transcoding URL (which is just a remux and not a transcode; unless it is)
' The web handles this by disabling EnableDirectPlay on a Retry, but we don't currently Retry a Live
' TV stream, thus we just turn it off on the first try here.
if mediaSourceId <> ""
params.MediaSourceId = mediaSourceId
else
' No mediaSourceId? Must be LiveTV...
params.EnableDirectPlay = false
end if

if audioTrackIndex > -1 then params.AudioStreamIndex = audioTrackIndex

Expand Down
21 changes: 20 additions & 1 deletion source/utils/deviceCapabilities.bs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,26 @@ function getCodecProfiles() as object
if di.CanDecodeAudio({ Codec: audioCodec, ChCnt: audioChannel }).Result
channelSupportFound = true
for each codecType in ["VideoAudio", "Audio"]
if audioCodec = "opus" and codecType = "Audio"
if audioCodec = "aac"
codecProfiles.push({
"Type": codecType,
"Codec": audioCodec,
"Conditions": [
{
"Condition": "NotEquals",
"Property": "AudioProfile",
"Value": "Main",
"IsRequired": true
},
{
"Condition": "LessThanEqual",
"Property": "AudioChannels",
"Value": audioChannel,
"IsRequired": true
}
]
})
else if audioCodec = "opus" and codecType = "Audio"
' opus audio files not supported by roku
else
codecProfiles.push({
Expand Down

0 comments on commit 4f1f333

Please sign in to comment.