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

Audio Pause Button won't show up

I have been trying to add an audio pause button for my channel that is based off of the video player example in the sdk. I added code to try and make a pause button show up after the audio is played Can anyone help me get this audio pause button working properly? Any help would be greatly appreciated. 😄

I added this code to my AppDetail.brs

screen.ClearButtons()

If showlist[showindex].contenttype<> "Audio" then



if regread(show.contentid) <> invalid and regread(show.contentid).toint() >=30 then

screen.AddButton(1, "Resume playing")

screen.AddButton(2, "Play from beginning")

else

screen.addbutton(2,"Play")

end if

screen.SetContent(show)

screen.Show()

else

if m.isplaying=true and not m.ispaused then

screen.addbutton(3,"Pause")

screen.addbutton(4,"Stop")

else if m.isplaying and m.ispaused then

screen.addbutton(5,"Resume")

screen.addbutton(4,"Stop")

else if not m.isplaying then

screen.addbutton(2,"Play")

end if

end if


Here is my appDetailScreen.brs:


if validateParam(show, "roAssociativeArray", "getPrevShow") = false return -1

return prevIndex
End Function












this is my appMain.brs:


)
canvas.Show()



Main()


End Sub


'********************************************************************
'** Video Player Example Application - Main
'** November 2009
'** Copyright (c) 2009 Roku Inc. All Rights Reserved.
'********************************************************************

Sub Main()

'initialize theme attributes like titles, logos and overhang color
initTheme()

'prepare the screen for display and get ready to begin
screen=preShowHomeScreen("", "")
if screen=invalid then
print "unexpected error in preShowHomeScreen"
return
end if

'set to go, time to get started
m.isplaying=false
m.ispaused=false
showHomeScreen(screen)

End Sub

'*************************************************************
'** Set the configurable theme attributes for the application
'**
'** Configure the custom overhang and Logo attributes
'** Theme attributes affect the branding of the application
'** and are artwork, colors and offsets specific to the app
'*************************************************************


Sub initTheme()

app = CreateObject("roAppManager")
theme = CreateObject("roAssociativeArray")

theme.OverhangOffsetSD_X = "50"
theme.OverhangOffsetSD_Y = "38"
theme.OverhangSliceSD = "pkg:/images/jbsoverhangsliceSD.jpg"
theme.OverhangLogoSD = "pkg:/images/jbsoverhanglogoSD.jpg"

theme.OverhangOffsetHD_X = "35"
theme.OverhangOffsetHD_Y = "35"
theme.OverhangSliceHD = "pkg:/images/jbsoverhangsliceHD.jpg"
theme.OverhangLogoHD = "pkg:/images/jbsoverhanglogoHD.jpg"

theme.BackgroundColor = "#000000"

app.SetTheme(theme)

End Sub







This is my showFeed.brs:

if e <> invalid then
item.StreamBitrates.Push(strtoi(validstr(e.streamBitrate.GetText())))
item.StreamQualities.Push(validstr(e.streamQuality.GetText()))
item.StreamUrls.Push(validstr(e.streamUrl.GetText()))
endif
next idx

showCount = showCount + 1
feed.Push(item)

skipitem:

next

End Function


0 Kudos
6 REPLIES 6
belltown
Roku Guru

Re: Audio Pause Button won't show up

If you're trying to add audio to the VideoPlayer example then try the code here: http://forums.roku.com/viewtopic.php?f=34&t=51192
0 Kudos
axiomy
Visitor

Re: Audio Pause Button won't show up

Belltown I tried that code from your example and the channel loads but it won't load or play anything from the xml.


here is the xml codes i have tried:
            <item sdImg="http://axiomy.com/blood/images/jackbloodSD.jpg" hdImg="http://axiomy.com/blood/images/jackbloodHD.jpg">
<title>The Jack Blood Show – July 3 2012</title>
<contentId>10043</contentId>
<contentType>Talk Radio</contentType>
<contentQuality>SD</contentQuality>
<contentFormat>audio</contentFormat>
<streamFormat>mp3</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>64</streamBitrate>
<audiostreamurl>http://deadlinelive.info/podpress_trac/feed/20883/0/jb070312.mp3</audiostreamurl>
<streamUrl>http://deadlinelive.info/podpress_trac/feed/20883/0/jb070312.mp3</streamUrl>
</media>
<synopsis>The Jack Blood Show the ins and outs of the phony “Arab Spring” July 3 2012</synopsis>
<genres>talk</genres>
<runtime>7200</runtime>
</item>



I also tried this:
            <item sdImg="http://axiomy.com/blood/images/jackbloodSD.jpg" hdImg="http://axiomy.com/blood/images/jackbloodHD.jpg">
<title>The Jack Blood Show – July 3 2012</title>
<contentId>10043</contentId>
<contentType>Talk Radio</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>mp3</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>64</streamBitrate>
<streamUrl>http://deadlinelive.info/podpress_trac/feed/20883/0/jb070312.mp3</streamUrl>
</media>
<synopsis>The Jack Blood Show the ins and outs of the phony “Arab Spring” July 3 2012</synopsis>
<genres>talk</genres>
<runtime>7200</runtime>
</item>



for what ever reason they just wont play.
0 Kudos
belltown
Roku Guru

Re: Audio Pause Button won't show up

You have invalid UTF-8 characters in your XML file.

In the following line replace the en-dash with a hyphen:

<title>The Jack Blood Show - July 3 2012</title>

should be:

<title>The Jack Blood Show - July 3 2012</title>


And in the following line replace the left and right double quotation marks with double quotes:

<synopsis>The Jack Blood Show the ins and outs of the phony “Arab Spring” July 3 2012</synopsis>

should be:

<synopsis>The Jack Blood Show the ins and outs of the phony "Arab Spring" July 3 2012</synopsis>


The dash looks like a hyphen, but in the code you posted it's not, and the Roku will not parse the XML if it contains characters that are not encoded in UTF-8.
0 Kudos
axiomy
Visitor

Re: Audio Pause Button won't show up

Thanks for letting me know that. I did remove all dashes and quotes and it still wont load. It wont go to the play screen.
0 Kudos
belltown
Roku Guru

Re: Audio Pause Button won't show up

The following works for me.

In the categories.xml file on your server:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>

<!-- banner_ad: optional element which displays an at the top level category screen -->
<banner_ad sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/missing.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/missing.png"/>

<category title="Audio" description="Test Audio Feed" sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Design.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Design.png">
<categoryLeaf title="Audio Feed" description="" feed="http://name_of_my_xml_file.xml"/>
</category>

</categories>


Substitute http://name_of_my_xml_file.xml with the url of the file on your server containing the following Xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<feed>
<!-- resultLength indicates the total number of results for this feed -->
<resultLength>1</resultLength>
<!-- endIndix indicates the number of results for this *paged* section of the feed -->
<endIndex>1</endIndex>
<item sdImg="http://axiomy.com/blood/images/jackbloodSD.jpg" hdImg="http://axiomy.com/blood/images/jackbloodHD.jpg">
<title>The Jack Blood Show - July 3 2012</title>
<contentId>10043</contentId>
<contentType>Talk Radio</contentType>
<contentQuality>SD</contentQuality>
<contentFormat>audio</contentFormat>
<streamFormat>mp3</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>64</streamBitrate>
<audiostreamurl>http://deadlinelive.info/podpress_trac/feed/20883/0/jb070312.mp3</audiostreamurl>
<streamUrl>http://deadlinelive.info/podpress_trac/feed/20883/0/jb070312.mp3</streamUrl>
</media>
<synopsis>The Jack Blood Show the ins and outs of the phony "Arab Spring" July 3 2012</synopsis>
<genres>talk</genres>
<runtime>7200</runtime>
</item>
</feed>


Try testing it with these files. And make sure that in your categoryFeed.brs file you've set conn.UrlPrefix to point to the directory on your own server containing your xml files.

Also, check the debugger output. With the original Xml you posted there was a debugger message that the Xml failed to parse.
0 Kudos
axiomy
Visitor

Re: Audio Pause Button won't show up

Belltown thank you! when I tested it off the the original sdk videoplayer it worked. I was able to get the pause button to show up. Thanks again! 😄
0 Kudos