Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
srbsdean
Visitor

Bypass Category Feed and go to Video Player

I really need some help. I have tried unsuccessfully to add a direct link to a video from my channel's home screen - bypassing the category feed. I am using the video player example that utilizes categories, and I have been able to (with the help of some on this forum) to add an "About Us" page that doesn't access my category feed. I need to do the same with a video player.

What I have done is change my appHomeScreeen.brs file so that I have added a
if kid.type = "About Us" then
ShowParagraphScreen()
if kid.type = "Orientation" then
ShowVideoScreen()

and
Function initCategoryList() As Void

conn = InitCategoryFeedConnection()

m.Categories = conn.LoadCategoryFeed(conn)
m.Categories.Kids.Push({ Type: "Orientation", ShortDescriptionLine1: "Orientation", ShortDescriptionLine2: "Who We Are", HDPosterUrl: "http://dsoeehox1xjyp.cloudfront.net/roku/WMI/images/orientation-HD.jpg", SDPosterUrl: "http://dsoeehox1xjyp.cloudfront.net/roku/WMI/images/orientation-SD.jpg" })
m.CategoryNames = conn.GetCategoryNames(m.Categories)

m.Categories = conn.LoadCategoryFeed(conn)
m.Categories.Kids.Push({ Type: "About Us", ShortDescriptionLine1: "About Us", ShortDescriptionLine2: "Learn more about World Ministries International", HDPosterUrl: "http://dsoeehox1xjyp.cloudfront.net/roku/WMI/images/about-us-HD.png", SDPosterUrl: "http://dsoeehox1xjyp.cloudfront.net/roku/WMI/images/about-us-SD.png" })
m.CategoryNames = conn.GetCategoryNames(m.Categories)

End Function


so that it, in theory, can reference my Orientation.brs which is my "showVideoScreen" file. Here is my orientation.brs file:
    '**********************************************************************
' This example function is passed an associative array representing a ' piece of content (e.g. a TV episode) There are other attributes
' (title, description, etc.) but this example focuses on showing
' attributes required for initiating playback. It creates a video
' screen, sets the content and starts playback by calling Show()
'**********************************************************************
Function showVideoScreen(episode As Object)
if type(episode) <> "roAssociativeArray" then
print "invalid data passed to showVideoScreen"
return -1
endif
port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
' Note: HDBranded controls whether the "HD" logo is displayed for a
' title. This is separate from IsHD because its possible to
' have an HD title where you don't want to show the HD logo
' branding for the title. Set these two as appropriate for
' your content
episode.HDBranded = false
episode.IsHD = false
' Note: The preferred way to specify stream info in v2.6 is to use
' the Stream roAssociativeArray content meta data parameter.

episode.Stream = { url:"http://dsoeehox1xjyp.cloudfront.net/roku/WMI/video/orientation/WMI-orientation.mp4",
bitrate:1500
quality:false
contentid:"2001"
}
episode.StreamFormat: "mp4"
' now just tell the screen about the title to be played, set the
' message port for where you will receive events and call show to
' begin playback. You should see a buffering screen and then
' playback will start immediately when we have enough data buffered.
screen.SetContent(video)
screen.SetMessagePort(port)
screen.Show()
' Wait in a loop on the message port for events to be received.
' We will just quit the loop and return to the calling function
' when the users terminates playback, but there are other things
' you could do here like monitor playback position and see events
' from the streaming player. Look for status messages from the video
' player for status and failure events that occur during playback
while true
msg = wait(0, port)

if type(msg) = "roVideoScreenEvent" then
print "showVideoScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isStatusMessage()
print "status message: "; msg.GetMessage()
else if msg.isPlaybackPosition()
print "playback position: "; msg.GetIndex()
else if msg.isFullResult()
print "playback completed"
exit while
else if msg.isPartialResult()
print "playback interrupted"
exit while
else if msg.isRequestFailed()
print "request failed – error: "; msg.GetIndex();" – "; msg.GetMessage()
exit while
end if
end if
end while
End Function


The problem, it is not working and I am not familiar enough to determine why. Can someone please help!! Here is my output from the debug console:
ing: 2ms
showHomeScreen | msg = | index = 0
list item selected | index = 0
only 1 category
Current Function:
016: Function InitShowFeedConnection(category As Object) As Object
017:
018: if validateParam(category, "roAssociativeArray", "initShowFeedConnectio
n") = false return invalid
019:
020: conn = CreateObject("roAssociativeArray")
021: conn.UrlShowFeed = category.feed
022:
023: conn.Timer = CreateObject("roTimespan")
024:
025: conn.LoadShowFeed = load_show_feed
026: conn.ParseShowFeed = parse_show_feed
027: conn.InitFeedItem = init_show_feed_item
028:
029: print "created feed connection for " + conn.UrlShowFeed
030: return conn
031:
032: End Function
Type Mismatch. (runtime error &h18) in ...Kp7M/pkg:/source/showFeed.brs(29)
029: print "created feed connection for " + conn.UrlShowFeed
Backtrace:
Function initshowfeedconnection(category As Object) As Object
file/line: /tmp/plugin/CEAAAApEKp7M/pkg:/source/showFeed.brs(29)
Function getshowsforcategoryitem(category As Object, item As Integer) As Object
file/line: /tmp/plugin/CEAAAApEKp7M/pkg:/source/appPosterScreen.brs(132)
Function showposterscreen(screen As Object, category As Object) As Integer
file/line: /tmp/plugin/CEAAAApEKp7M/pkg:/source/appPosterScreen.brs(50)
Function displaycategoryposterscreen(category As Object) As Dynamic
file/line: /tmp/plugin/CEAAAApEKp7M/pkg:/source/appHomeScreen.brs(75)
Function showhomescreen(screen As Dynamic) As Integer
file/line: /tmp/plugin/CEAAAApEKp7M/pkg:/source/appHomeScreen.brs(52)
Function main() As Void
file/line: /tmp/plugin/CEAAAApEKp7M/pkg:/source/appMain.brs(20)

Local Variables:
category &h4010 bsc:roAssociativeArray, refcnt=2
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=7
conn &h0010 bsc:roAssociativeArray, refcnt=1
BrightScript Debugger> Note: GC - Found 24 orphaned objects (objects in a circul
ar ref loop).
------ Running ------
Type args = roAssociativeArray
Type args.url = Invalid
showSpringboardScreen
Button pressed: 1 0
Displaying video:
srt = file://pkg:/source/craigventer.srt
Unknown event: 20 msg: Stream started.
Unknown event: 31 msg: Download segment info
Unknown event: 27 msg: HLS segment info
Unknown event: 31 msg: Download segment info
Unknown event: 31 msg: Download segment info
Unknown event: 15 msg: Playback interrupted by user.
Closing video screen
Screen closed
*** ERROR compiling /pkg:/source/orientation.brs:
SUB or FUNCTION defined twice. (compile error &had) in ...n/pkg:/source/orientat
ion.brs(7)
*** ERROR compiling /pkg:/source/orientation.brs:
SUB or FUNCTION defined twice. (compile error &had) in ...4/pkg:/source/orientat
ion.brs(7)
*** ERROR compiling /pkg:/source/appHomeScreen.brs:
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(60)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(64)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(73)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(80)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(90)
*** ERROR compiling /pkg:/source/appHomeScreen.brs:
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(60)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(64)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(73)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(80)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(90)
*** ERROR compiling /pkg:/source/appHomeScreen.brs:
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(60)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(64)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(73)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(80)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(90)
*** ERROR compiling /pkg:/source/appHomeScreen.brs:
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(60)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(64)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(73)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(80)
Syntax Error. (compile error &h02) in ...pkg:/source/appHomeScreen.brs(90)


Thank you for any help you can offer. If there is an easier way to do what I am trying to do, please let me know.

Dean Anderson
0 Kudos
1 REPLY 1
RokuJoel
Binge Watcher

Re: Bypass Category Feed and go to Video Player

I would look at the function that displays your channel's home screen and see what where you can check for the type of content you wish to link directly to. Since your channel is based on the videoplayer example:

if kid.type = "special_category" then


so then if you go into the XML, for example in the TED Talks XML, change

<category title="Technology" descr...


to

<specialCategory  title="Technology" descr...


that should make the app call displaySpecialCategoryScreen()

like
displaySpecialCategoryScreen(content_item)


Of course you need more information for that content item, you'll probably want to reuse some of the functions that are already in this example for retrieving and parsing xml, and then have that the displaySpecialCategoryScreen() function call your video playback function and pass in the data for video playback.

- Joel
0 Kudos