Play local trailers (#761)

This commit is contained in:
1hitsong 2022-09-03 03:31:15 -04:00 committed by GitHub
parent 65daaea7a7
commit 524e3f0ec7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 730 additions and 696 deletions

View File

@ -19,6 +19,9 @@ sub init()
m.buttonGrp.setFocus(true)
m.top.lastFocus = m.buttonGrp
m.trailerButton = m.top.findNode("trailer-button")
m.trailerButton.text = tr("Play Trailer")
m.top.observeField("itemContent", "itemContentChanged")
end sub
@ -31,6 +34,9 @@ sub OnScreenShown()
end if
end sub
sub trailerAvailableChanged()
m.trailerButton.visible = m.top.trailerAvailable
end sub
sub itemContentChanged()
' Updates video metadata

View File

@ -2,9 +2,7 @@
<component name="MovieDetails" extends="JFScreen">
<children>
<LayoutGroup id="main_group" layoutDirection="horiz" itemSpacings="[30]">
<Poster id="moviePoster"
translation="[250,150]"
width="300" height="450" />
<Poster id="moviePoster" translation="[250,150]" width="300" height="450" />
<LayoutGroup layoutDirection="vert" translation="[455, 150]" itemSpacings="[25]" id="details">
<LayoutGroup layoutDirection="horiz" itemSpacings="[100]" id="infoGroup">
<Label id="releaseYear" />
@ -22,19 +20,20 @@
</LayoutGroup>
<Label id="genres" />
<Label id="director" />
<LayoutGroup layoutDirection="horiz" >
<LayoutGroup layoutDirection="horiz">
<Label id="video_codec" vertAlign="bottom" height="39" />
<label id="video_codec_count" font="font:smallestSystemFont" vertAlign="top" color="#ceffff" />
</LayoutGroup>
<LayoutGroup layoutDirection="horiz" >
<LayoutGroup layoutDirection="horiz">
<Label id="audio_codec" vertAlign="bottom" height="39" />
<label id="audio_codec_count" font="font:smallestSystemFont" vertAlign="top" color="#ceffff" />
</LayoutGroup>
<ButtonGroupHoriz id="buttons" itemSpacings="[10]">
<Button text="Play" id="play-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button text="Options" id="options-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button text="Play" id="play-button" iconUri="" focusedIconUri="" maxWidth="175" minWidth="175" />
<Button text="Options" id="options-button" iconUri="" focusedIconUri="" maxWidth="250" minWidth="250" />
<Button text="Watched" id="watched-button" iconUri="" focusedIconUri="" maxWidth="350" minWidth="300" />
<Button text="Favorite" id="favorite-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button id="trailer-button" visible="false" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
</ButtonGroupHoriz>
<Label id="tagline" />
<Label id="overview" wrap="true" maxLines="8" />
@ -46,6 +45,7 @@
</children>
<interface>
<field id="itemContent" type="node" />
<field id="trailerAvailable" type="bool" onChange="trailerAvailableChanged" value="false" />
<field id="selectedAudioStreamIndex" type="integer" />
<field id="selectedVideoStreamId" type="string" />
</interface>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_US" sourcelanguage="en_US">
<defaultcodec>UTF-8</defaultcodec>
<context>
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>default</name>
<message>
<source>192.168.1.100:8096 or https://example.com/jellyfin</source>
@ -688,8 +688,9 @@
<source>Skip Intro</source>
<translation>Skip Intro</translation>
</message>
</context>
<context>
<name></name>
</context>
<message>
<source>Play Trailer</source>
<translation>Play Trailer</translation>
</message>
</context>
</TS>

View File

@ -276,6 +276,23 @@ sub Main (args as dynamic) as void
sceneManager.callFunc("pushScene", video)
end if
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
end if
else if btn <> invalid and btn.id = "trailer-button"
audio_stream_idx = 1
mediaSourceId = invalid
video_id = group.id
trailerData = api_API().users.getlocaltrailers(get_setting("active_user"), group.id)
video_id = trailerData[0].id
video = CreateVideoPlayerGroup(video_id, mediaSourceId, audio_stream_idx)
if video <> invalid and video.errorMsg <> "introaborted"
sceneManager.callFunc("pushScene", video)
end if
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
end if

View File

@ -338,6 +338,12 @@ function CreateMovieDetailsGroup(movie)
movie = ItemMetaData(movie.id)
group.itemContent = movie
group.trailerAvailable = false
trailerData = api_API().users.getlocaltrailers(get_setting("active_user"), movie.id)
if isValid(trailerData)
group.trailerAvailable = trailerData.Count() > 0
end if
buttons = group.findNode("buttons")
for each b in buttons.getChildren(-1, 0)

View File

@ -109,6 +109,10 @@ function ItemMetaData(id as string)
tmp.image = PosterImage(data.id)
tmp.json = data
return tmp
else if data.type = "Trailer"
tmp = CreateObject("roSGNode", "VideoData")
tmp.json = data
return tmp
else if data.type = "TvChannel" or data.type = "Program"
tmp = CreateObject("roSGNode", "ChannelData")
tmp.image = PosterImage(data.id)