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: 
tintumonkb
Visitor

video player sdk with differnt xml format. need some help

Hello roku developers,
im new to roku development,im developing a roku channel using video player (ted talks) sdk file.
i have an xml file,which looks differnet than ted talks xml format. please look at this link.
http://tecmediainc.atspace.co.uk/live_playingnow.xml
it has 7 live channel example. this links will change every 3 day. so i need an app to support this xml format.
can someone help me to create a roku app supporting this xml format.
or someone make me one. i really appreciate your help thank you 🙂
i dont know where to start.and i dont know bright script programming.
0 Kudos
6 REPLIES 6
belltown
Roku Guru

Re: video player sdk with differnt xml format. need some hel

If your Xml file has a simple, single-layer structure, like the one in your link, then all you need is a single .brs file.

The easiest way to get it up and running is to take the customvideoplayer channel and replace the entire contents of main.brs with this code:


sub main ()

xml = readXml ("http://tecmediainc.atspace.co.uk/live_playingnow.xml", 5000)

if xml <> invalid
contentList = getContentList (xml)
displayPoster (contentList)
endif

end sub

function getContentList (xml as object) as object

contentList = []
for each item in xml.item
categoriesList = []
for each genre in item.genres
categoriesList.Push (genre.GetText ())
end for
if item.live.GetText () = "true" then live = true else live = false
contentList.Push ({
ShortDescriptionLine1: item.title.GetText (),
ShortDescriptionLine2: item.synopsis.GetText (),
SDPosterUrl: item@sdImg,
HDPosterUrl: item@hdImg,
Description: item.synopsis.GetText (),
StreamFormat: item.streamFormat.GetText (),
StreamUrls: [item.streamMinUrl.GetText ()],
StreamQualities: [item.streamQuality.GetText ()],
StreamContentIDs: [item.contentId.GetText ()],
StreamBitrates: [0],
Live: live,
Title: item.title.GetText (),
Length: item.runtime.GetText ().ToInt (),
Categories: categoriesList
})
end for

return contentList

end function

sub displayPoster (contentList as object)

port = CreateObject ("roMessagePort")
poster = CreateObject ("roPosterScreen")
poster.SetMessagePort (port)
poster.SetListStyle ("flat-category")
poster.SetBreadcrumbEnabled (true)
poster.SetBreadcrumbText ("tintumonkb's videos", "")
poster.SetContentList (contentList)
poster.SetFocusedListItem (0)
poster.Show ()

while true
msg = Wait (0, port)
if type (msg) = "roPosterScreenEvent"
if msg.IsScreenClosed ()
exit while
else if msg.IsListItemSelected ()
index = displaySpringboard (contentList, msg.GetIndex ())
poster.SetFocusedListItem (index)
endif
endif
end while

end sub

function displaySpringboard (contentList as object, index as integer) as integer

content = contentList [index]

port = CreateObject ("roMessagePort")
screen = CreateObject ("roSpringboardScreen")
screen.SetMessagePort (port)
screen.SetDescriptionStyle ("movies")
screen.SetPosterStyle ("rounded-square-generic")
screen.SetBreadcrumbEnabled (true)
screen.SetBreadcrumbText ("tintumonkb's videos", "")
screen.SetStaticRatingEnabled (false)
screen.AllowNavLeft (true)
screen.AllowNavRight (true)
screen.AddButton (1,"Play Video")
screen.SetContent (content)
screen.Show ()

while true
msg = Wait (0, port)
if type (msg) = "roSpringboardScreenEvent"
if msg.IsScreenClosed ()
exit while
else if msg.IsButtonPressed ()
if msg.GetIndex () = 1 ' Play
displayVideo (content)
endif
else if msg.IsRemoteKeyPressed ()
key = msg.GetIndex ()
if key = 4 ' Back Key - Display previous movie
index = index - 1 : if index < 0 then index = contentList.Count () - 1
content = contentList [index]
screen.SetContent (contentList [index])
screen.Show ()
else if key = 5 ' Forward Key - Display next movie
index = index + 1 : if index >= contentList.Count () then index = 0
content = contentList [index]
screen.SetContent (contentList [index])
screen.Show ()
endif
endif
endif
end while
return index
end function

sub displayVideo (content as object)

port = CreateObject ("roMessagePort")
video = CreateObject ("roVideoScreen")
video.SetMessagePort (port)
video.SetContent (content)
video.Show ()

while true
msg = Wait (0, port)
if type (msg) = "roVideoScreenEvent"
if msg.IsScreenClosed ()
exit while
else if msg.IsPlaybackPosition ()
debug ("isPlayBackPosition")
else if msg.IsRequestFailed ()
debug ("play failed: " + msg.GetMessage () + " Index: " + msg.GetIndex ().ToStr ())
else
debug ("Unknown event: " + msg.GetType ().ToStr () + " msg: " + msg.GetMessage ())
endif
else
debug ("Unknown message type: " + type (msg))
endif
end while

end sub

function readXml (fileName as string, timeout = 0 as integer) as object

xml = Invalid

ut = CreateObject ("roUrlTransfer")
port = CreateObject ("roMessagePort")
ut.SetPort (port)
ut.SetUrl (fileName)

data = ""
if not ut.AsyncGetToString ()
debug ("readXml AsyncGetToString Failed")
else
while true
msg = Wait (timeout, port)
if type (msg) = "Invalid" ' Operation timed out
debug ("readXml Request Timed Out")
ut.AsyncCancel ()
exit while
else if type (msg) = "roUrlEvent"
if msg.GetInt () <> 1
debug ("readXml Request Transfer Did Not Complete")
else
status = msg.GetResponseCode ()
debug ("readXml Request: msg.ResponseCode () = " + status.ToStr () + ". msg.GetFailureReason () = " + msg.GetFailureReason ())
if status <> 200
debug ("readXml Request Did Not Succeed")
else
data = msg.GetString ()
if data = ""
debug ("readXml Request Returned No Data")
else
' We have data
debug ("readXml Response: " + data)
endif
endif
endif
exit while
endif
end while
endif

' Only proceed if data was read
if data <> ""
' Only proceed if the data contains Xml that can be parsed
xml = CreateObject ("roXMLElement")
if not xml.Parse (data)
debug ("readXml Response Parsing Failed")
xml = Invalid
endif
endif

return xml

end function

' In production code, remove the comment from the return statement
sub debug (message as string)
'return
dt = CreateObject ("roDateTime")
dt.Mark ()
dt.ToLocalTime ()
hh = Right ("0" + dt.GetHours ().ToStr (), 2)
mm = Right ("0" + dt.GetMinutes ().ToStr (), 2)
ss = Right ("0" + dt.GetSeconds ().ToStr (), 2)
mmm = Right ("00" + dt.GetMilliseconds ().ToStr (), 3)
print hh + ":" + mm + ":" + ss + "." mmm + " " + message
end sub


Note that you have 4 stream Urls in your Xml, each specifying a different HLS stream. You can only specify a single stream for HLS. I just picked one at random. The m3u8 file you specify should contain a list of streams of varying bitrates.
0 Kudos
tintumonkb
Visitor

Re: video player sdk with differnt xml format. need some hel

sir i dont know where do i need to put this code in which brs file.you ment i need to create single.brs file and put that to source in video player sdk ?
im sorry for asking but if you dont mind. can you make the app and zip file it ,and send to me.i only know html and some css coding. this is my first time with coding. sorry if im bothering you. thank you
0 Kudos
belltown
Roku Guru

Re: video player sdk with differnt xml format. need some hel

"tintumonkb" wrote:
sir i dont know where do i need to put this code in which brs file.you ment i need to create single.brs file and put that to source in video player sdk ?
im sorry for asking but if you dont mind. can you make the app and zip file it ,and send to me.i only know html and some css coding. this is my first time with coding. sorry if im bothering you. thank you

I just edited the post after you read it. I think it explains it better now. Also I made a couple of changes to the code. If you've copied it already you may want to take a newer copy.
0 Kudos
tintumonkb
Visitor

Re: video player sdk with differnt xml format. need some hel

hey again, i downloaded customvideo player sdk and put the code you made for me with main.brs but im getting error
Application Received: 119126 bytes stored.

Install Failure: Compilation Failed.
0 Kudos
belltown
Roku Guru

Re: video player sdk with differnt xml format. need some hel

"tintumonkb" wrote:
hey again, i downloaded customvideo player sdk and put the code you made for me with main.brs but im getting error
Application Received: 119126 bytes stored.

Install Failure: Compilation Failed.

A couple of things to try:
1. Try copying the code again. Delete the entire contents of main.brs, copy my code again and paste into the file. Take a look at the code after it's copied, particularly the beginning and end to make sure everything got copied correctly.
2. Make sure there is only one file, main.brs in the 'source' directory.
3. Delete the .zip file and re-zip the contents of the folder containing the directories and files: fonts/images/source/Makefile/manifest
4. Look at the .zip file you've generated and make sure it ONLY contains: fonts/images/source/Makefile/manifest
5. Look at the .zip file and make sure the 'source' directory ONLY contains main.brs
6. Try to side-load the channel again. Make sure you have the correct zip file.
7. Telnet from your computer to your Roku's IP address at port 8085 to see if there are any messages about why the compilation failed
8. If you don't have telnet you should be able to look at that info from your web browser, go to your <Roku IP Address>:8085
0 Kudos
tintumonkb
Visitor

Re: video player sdk with differnt xml format. need some hel

sir, thank you so much. it worked great. you are genius.now im so happy 🙂
thanks alot
0 Kudos