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

Combining Audio and Video...

Please excuse me if this is answered somewhere but I could not find it.

I have been able to edit the audio player example and get it to work on one private channel, and I've been able to do the same with the video player example on another private channel. What I can't seem to figure out is how to combine the two, so my main menu will show two categories, audio and video. I'm sure it's not that hard, but I can't seem to find the right document.

Thank you!

AL
Al
Creator, Producer, and Co-Host - Country Dreams radio show
http://www.countrydreamsradio.com
Founder - Independent Country Music Association
http://www.icmanet.com
Station Engineer - WBTN 1370 AM
http://www.wbtnam.org
0 Kudos
43 REPLIES 43
destruk
Binge Watcher

Re: Combining Audio and Video...

0 Kudos
ncognito66
Visitor

Re: Combining Audio and Video...

Destruk,,,thanks so much...I was going buggy searching!!
Al
Creator, Producer, and Co-Host - Country Dreams radio show
http://www.countrydreamsradio.com
Founder - Independent Country Music Association
http://www.icmanet.com
Station Engineer - WBTN 1370 AM
http://www.wbtnam.org
0 Kudos
ncognito66
Visitor

Re: Combining Audio and Video...

Well I found the code in the other post, but no real instructions on "where" to put it. I assume that was based off the VideoPlayer example anyway.

I have started with the AudioApp example...I now have 6 categories set up, but I want two of them to be video. I also need to add sub-categories under those audio/video categories, but once again everything I've found starts with the VideoPlayer example, not the Audio example.

Any help would be greatly appreciated. I'm proficient in HTML, PHP, CSS, but this language I don't have a clue yet.
Al
Creator, Producer, and Co-Host - Country Dreams radio show
http://www.countrydreamsradio.com
Founder - Independent Country Music Association
http://www.icmanet.com
Station Engineer - WBTN 1370 AM
http://www.wbtnam.org
0 Kudos
RokuJoel
Binge Watcher

Re: Combining Audio and Video...

go back to the videoplayer example. Modify your XML to include a field that says audio or video, like:

<contentformat>audio</contentformat>
and also, if it is audio, then add something like

<audiostreamurl>http://myserver.com/myfile.mp3</audiostreamurl>

and of course set the streamformat to mp3 or mp4 depending on the content type.

add a parser for that field to the parse_show_feed function.

item.contentformat = validstr(curShow.contentformat.GetText())
item.audiostreamurl = validstr(curShow.audiostreamurl.GetText())

In your Springboard screen code, check if the contentformat=audio or video, if not video, call your audioplayer function:


if msg.GetIndex() = 2
if showlist[showindex].contentformat <> "audio" then
showList[showIndex].PlayStart = 0
showVideoScreen(showList[showIndex])
refreshShowDetail(screen,showList,showIndex)
else
playaudio(showlist[showindex))
refreshShowDetail(screen,showList,showIndex)
end if
endif


That should provide you with a rough outline of how to do it.

- Joel
0 Kudos
ncognito66
Visitor

Re: Combining Audio and Video...

Thanks Joel!

So basically everything I've done in the AudioPlayer must be redone in the VideoPlayer example then?

And I'm not seeing a "Springboard.brs" in the videoPlayer folder like in the audio folder....which file am I looking at?

Thanks!
Al
Creator, Producer, and Co-Host - Country Dreams radio show
http://www.countrydreamsradio.com
Founder - Independent Country Music Association
http://www.icmanet.com
Station Engineer - WBTN 1370 AM
http://www.wbtnam.org
0 Kudos
ncognito66
Visitor

Re: Combining Audio and Video...

Found it (I think) in the appDetailScreen.brs file.

Thanks again!
Al
Creator, Producer, and Co-Host - Country Dreams radio show
http://www.countrydreamsradio.com
Founder - Independent Country Music Association
http://www.icmanet.com
Station Engineer - WBTN 1370 AM
http://www.wbtnam.org
0 Kudos
RokuJoel
Binge Watcher

Re: Combining Audio and Video...

Not sure if what you did in audioplayer would directly translate or not would have to see your code.

My opinion is that people who really want to learn Brightscript should start off writing a channel from scratch instead of hacking an example to work, but I also understand that many people just want to publish content as quickly as possible.

a simple audio playback function might look like this (one stream only, not a playlist):

function playaudio(contentlist, index) as integer
audio=createobject("roaudioplayer")
audio.addcontent({url:contentlist[index].streamurl,streamformat:contentlist[index].streamformat})
port=createobject("romessageport")
audio.setport(port)
audio.play()
while true
msg=wait(0,port)
if lcase(type(msg))="roaudioplayerevent" then
if msg.isRequestSucceeded() then
return -1
else if msg.isrequestfailed() then
return -2
end if
end if
end while
end function
0 Kudos
ncognito66
Visitor

Re: Combining Audio and Video...

"RokuJoel" wrote:
go back to the videoplayer example. Modify your XML to include a field that says audio or video, like:

<contentformat>audio</contentformat>
and also, if it is audio, then add something like

<audiostreamurl>http://myserver.com/myfile.mp3</audiostreamurl>

and of course set the streamformat to mp3 or mp4 depending on the content type.

add a parser for that field to the parse_show_feed function.

item.contentformat = validstr(curShow.contentformat.GetText())
item.audiostreamurl = validstr(curShow.audiostreamurl.GetText())

In your Springboard screen code, check if the contentformat=audio or video, if not video, call your audioplayer function:


if msg.GetIndex() = 2
if showlist[showindex].contentformat <> "audio" then
showList[showIndex].PlayStart = 0
showVideoScreen(showList[showIndex])
refreshShowDetail(screen,showList,showIndex)
else
playaudio(showlist[showindex))
refreshShowDetail(screen,showList,showIndex)
end if
endif


That should provide you with a rough outline of how to do it.

- Joel


Okay, I added the new section to the parse_show_feed section:

'fetch all values from the xml for the current show
item.hdImg = validstr(curShow@hdImg)
item.sdImg = validstr(curShow@sdImg)
item.ContentId = validstr(curShow.contentId.GetText())
item.Title = validstr(curShow.title.GetText())
item.Description = validstr(curShow.description.GetText())
item.ContentType = validstr(curShow.contentType.GetText())
item.ContentQuality = validstr(curShow.contentQuality.GetText())
item.Synopsis = validstr(curShow.synopsis.GetText())
item.Genre = validstr(curShow.genres.GetText())
item.Runtime = validstr(curShow.runtime.GetText())
item.HDBifUrl = validstr(curShow.hdBifUrl.GetText())
item.SDBifUrl = validstr(curShow.sdBifUrl.GetText())

item.contentformat = validstr(curShow.contentformat.GetText())
item.audiostreamurl = validstr(curShow.audiostreamurl.GetText())

item.StreamFormat = validstr(curShow.streamFormat.GetText())
if item.StreamFormat = "" then 'set default streamFormat to mp4 if doesn't exist in xml
item.StreamFormat = "mp4"
endif


and then I added the other code:

.PlayStart = PlayStart.ToInt()
endif
endif

if msg.GetIndex() = 3
endif
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
end if


Now I'm locking up at the opening screen.

Did I add the code in the right places?

Do I have to bring any code from the AudioPlayer app to play audios, or does it have that function hiding somewhere?

I'm learning as I go...thanks for the help....again! 😄
Al
Creator, Producer, and Co-Host - Country Dreams radio show
http://www.countrydreamsradio.com
Founder - Independent Country Music Association
http://www.icmanet.com
Station Engineer - WBTN 1370 AM
http://www.wbtnam.org
0 Kudos
RokuJoel
Binge Watcher

Re: Combining Audio and Video...

What does it say on your console? has it crashed to a brightscript prompt? If not, if you hit ctrl-c what was the last line that executed? That should hopefully give you a clue about what the problem is.

- Joel
0 Kudos