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: 
genepensiero
Roku Guru

Help With Deep Linking

Having trouble getting deep linking to work in my Roku channel.

I've done a lot of reading on the Roku SDK (particularly their Deep Linking Doc) and a variety of forums. However, I'm just not making any headway.

Currently, my channel uses the Simple Grid with Details template, which serves video content via RSS files.


Here's the beginning of my main.brs file:


sub Main(args as Dynamic) as Void

showSGScreen(args)

if (args.mediaType <> invalid) and (args.contentID <> invalid)
if (args.mediaType = "movie" or args.mediaType = "episode" or args.mediaType = "short-form" or args.mediaType = "series" or args.mediaType = "special")
   'play content directly
else
   'deep linking issue such as a contentID not matching any content in the partner's catalog
   'display an appropriate error message for the user
end if
else
'launch channel normally
end if

end sub

Sub RunUserInterface()
screen = CreateObject("roSGScreen")
scene = screen.CreateScene("HomeScene")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()

oneRow = GetApiArray1()
twoRow = GetApiArray2()
threeRow = GetApiArray3()
fourRow = GetApiArray4()

list = [
{
   TITLE : "Watch Our Services Live"
   ContentList : oneRow
}
{
   TITLE : "Without Ceasing: A Series On Prayer"
   ContentList : twoRow
}
{
   TITLE : "The Least Of These: Hope, Help, Heal"
   ContentList : threeRow
}
{
   TITLE : "The Bible: Learning To Live It"
   ContentList : fourRow
}


]
scene.gridContent = ParseXMLContent(list)

while true
   msg = wait(0, port)
   print "------------------"
   print "msg = "; msg
end while

if screen <> invalid then
   screen.Close()
   screen = invalid
end if
End Sub


Function ParseXMLContent(list As Object)
RowItems = createObject("RoSGNode","ContentNode")

for each rowAA in list
'for index = 0 to 1
   row = createObject("RoSGNode","ContentNode")
   row.Title = rowAA.Title

   for each itemAA in rowAA.ContentList
       item = createObject("RoSGNode","ContentNode")
       ' We don't use item.setFields(itemAA) as doesn't cast
streamFormat to proper value
       for each key in itemAA
           item[key] = itemAA[key]
       end for
       row.appendChild(item)
   end for
   RowItems.appendChild(row)
end for

return RowItems
End Function


Function GetApiArray1()
url = CreateObject("roUrlTransfer")
url.SetUrl("http://media.genepensiero.com/roku/rss/livestream.rss")
rsp = url.GetToString()

responseXML = ParseXML(rsp)
responseXML = responseXML.GetChildElements()
responseArray = responseXML.GetChildElements()

result = []

for each xmlItem in responseArray
   if xmlItem.getName() = "item"
       itemAA = xmlItem.GetChildElements()
       if itemAA <> invalid
           item = {}
           for each xmlItem in itemAA
               item[xmlItem.getName()] = xmlItem.getText()
               if xmlItem.getName() = "media:content"
                   item.stream = {url : xmlItem.url}
                   item.url = xmlItem.getAttributes().url
                   item.streamFormat = "hls"

                   mediaContent = xmlItem.GetChildElements()
                   for each mediaContentItem in mediaContent
                       if mediaContentItem.getName() =
"media:thumbnail"
                           item.HDPosterUrl =
mediaContentItem.getattributes().url
                           item.hdBackgroundImageUrl =
mediaContentItem.getattributes().url
                       end if
                   end for
               end if
           end for
           result.push(item)
       end if
   end if
end for

return result
End Function



Then an example of an entry in my RSS feed is:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
<channel>
   <title>Bright Light Church</title>
   <link />
   <description>Live and Archived Bible Studies</description>
   <language>en-us</language>
   <pubDate>Wed, 26 Apr 2017 12:00:00 PT</pubDate>
   <category>TV &amp; Film</category>
   <image>
       <title>The Bible</title>
       <url>http://media.genepensiero.com/roku/withoutceasing.jpg</url>
       <width>-1</width>
       <height>-1</height>
   </image>
   <item>
   <title>Prayer Pressure</title>
   <link>http://media.calvaryhanford.com/psalms/prayerpressure.mp4</link>
   <description>David brings big requests to God and receives a big revelation.</description>
   <pubDate>Sun, 05 Mar 2017 10:15:00 PT</pubDate>
   <guid isPermaLink="false">ch001</guid>
   <media:content channels="2" type="special" isDefault="true" id="ch001"  url="http://media.calvaryhanford.com/psalms/prayerpressure.mp4">
   <media:description>David brings big requests to God and receives a big revelation.</media:description>
   <media:keywords>church, bible study, expository sermon</media:keywords>
   <media:thumbnail url="http://media.genepensiero.com/roku/withoutceasing.jpg" />
   <media:title>Prayer Pressure</media:title>
   </media:content>
   </item>



When I use the Deep Link Tester it just opens my channel to the home screen, it doesn't launch the specific video.

Any insight would be appreciated.
0 Kudos
5 REPLIES 5
joetesta
Roku Guru

Re: Help With Deep Linking

where you have 'play content directly' you need to replace with code to launch the player, most likely the same way it would've been launched had the user navigated to that video, so that when they exit the video, they will land on a page where they could re-launch the same video.  I'm not familiar with "Simple Grid with Details template" but you may need to customize so that it can receive the video id as passed in on the deeplink and launch the appropriate video.
hope it may help
aspiring
0 Kudos
genepensiero
Roku Guru

Re: Help With Deep Linking

Thanks for the reply. I guess I'm just not grasping this concept. I've been trying to follow the SDK and the various suggestions on this forum, Stack Overflow, etc, yet nothing is really yielding results. 

I don't get why Roku's sample channels don't have Deep Linking built in for us to see when they're going to require it of every public channel. 
0 Kudos
joetesta
Roku Guru

Re: Help With Deep Linking

do you have a link to the sample channel you're using? 
aspiring
0 Kudos
genepensiero
Roku Guru

Re: Help With Deep Linking

0 Kudos
coldrain
Binge Watcher

Re: Help With Deep Linking

I almost agree with the first answer of joetesta. When your channel start and get the list of video from your feed, you need to index all of your video. When you finish, you look for video's indexed id that matches the args.contentID (and args.mediaType). Once you find out that video, just start it as normally.
By indexing, you are able to support the read/write video bookmark which is also a requirement for every video longer than 15s when publishing the channel.
0 Kudos