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

HLS stream link isnot working in custom video player SDk

Hello im having trouble, i developed a small app to watch my local channel in TV,
i developed in custom video player SDK but the hls link didnt open and play. but its working in instant tv channel roku development website
i need some help.
here is my main.brs file in Custom Video Player SDK Sample
sub main ()

xml = readXml ("http://www.razaqeensports.com/pottan/channel.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.genres.GetText (),
ShortDescriptionLine2: item.title.GetText (),
SDPosterUrl: item@sdImg,
HDPosterUrl: item@hdImg,
Description: item.title.GetText (),
StreamFormat: item.streamFormat.GetText (),
StreamUrls: [item.streamUrl.GetText ()],
StreamQualities: [item.streamQuality.GetText ()],
StreamContentIDs: [item.contentId.GetText ()],
StreamBitrates: [0],
Live: live,
Title: item.genres.GetText (),
Categories: categoriesList
})
end for

return contentList

end function

sub displayPoster (contentList as object)

port = CreateObject ("roMessagePort")
poster = CreateObject ("roPosterScreen")
poster.SetMessagePort (port)
poster.SetListStyle ("arced-landscape")
poster.SetBreadcrumbEnabled (true)
poster.SetBreadcrumbText ("", "")
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 ("", "")
screen.SetStaticRatingEnabled (false)
screen.AllowNavLeft (true)
screen.AllowNavRight (true)
screen.AddButton (1,"Play")
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

And Here is the XML file http://www.razaqeensports.com/pottan/channel.xml
Here is the live HLS Stream Link http://hls.iptv.optimum.net/news12/nipa ... n=N12TW_LI
Is it possible to hide or disable Springboard in custom video player , if it is, then please tell me how?, Thank you, appreciate your help.
0 Kudos
2 REPLIES 2
arifkhan
Visitor

Re: HLS stream link isnot working in custom video player SDk

Hi tintumonkb, I've tested your code and found your url may contain space, new line, etc and needed to trim like

StreamUrls: [item.streamUrl.GetText ().trim()],


Hope this will work for you.

Thanks,
Arif Khan
0 Kudos
tintumonkb
Visitor

Re: HLS stream link isnot working in custom video player SDk

Thank you sir, its really working. is it possible to disable the springboard i dont want to see the play, play from the beginning option, is it possible ?
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.