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

viewtopic.php?f=34&t=43548&p=311885&hilit=special#p295020

Destruk,thanks so much…I was going buggy searching!!

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.

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

audio
and also, if it is audio, then add something like

http://myserver.com/myfile.mp3

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

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!

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

Thanks again!

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

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

and also, if it is audio, then add something like

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! :grinning_face_with_smiling_eyes:

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

*** ERROR compiling /pkg:/source/appDetailScreen.brs:
Syntax Error. (compile error &h02) in …g:/source/appDetailScreen.brs(72)
Note: GC - Found 50 orphaned objects (objects in a circular ref loop).
*** ERROR compiling /pkg:/source/appDetailScreen.brs:
Syntax Error. (compile error &h02) in …g:/source/appDetailScreen.brs(72)

I’m assuming (72) refers to the line number? if so, here it is:

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

typo:

playaudio(showlist[showindex))

should be

playaudio(showlist[showindex])

square bracket instead of curved

  • Joel

Well sir..we’re getting closer!

It nivigates through the screens now, but when you actually go to play either an MP3 audio or an MP4 video, neither plays…it just kinda sits there.

The debugger shows:

playstart &h0000 val:Uninitialized
BrightScript Debugger> :smiling_face:Note: GC - Found 66 orphaned objects (objects in a circu
lar ref loop).

Now I’m getting "wrong number of function parameters. <runtime error &hf1> in …g:source/appDetailScreen.brs<72>

072: playaudio<showlist[showindex]>

Backtrace:
Function showdetailscreen<screen As , showlist As , showindex As Integer> As Integer

Pretty much each function says …

It also appears it’s not picking up the “audiostreamurl” as that listing is blank.

Here’s my .xml…look right?

Test MP3 file 10031 Music SD audio mp3 SD [http://www.hauntedamericaradio.com/audio/Episode10.mp3](http://www.hauntedamericaradio.com/audio/Episode10.mp3) Haunted America Radio Episode 10 Paranormal 3617

Video is working by the way…just the audio that won’t play now. Maybe I put the AudioPlayer in the wrong place? I placed it in the appVideoScreen.brs file.

I get the same thing. And I have the audio in the xml.

I think I have all my .xml files they way I need them, and the videos are playing. If I could just figure how where the audio player code belongs, and how come I’m getting an “unable to parse” error on the audio .xml files I think I’d be set.

Your right where do we insert into videoplayer the audio code function. My xml is ok, just where do we insert the function to make it work?

if they are not parsing, they are not valid xml, you can check your xml here:

http://www.w3schools.com/dom/dom_validate.asp

Remember, ampersands need to be replaced with &

Post an example if you can of your xml that isn’t working.

  • Joel

Joel:

We have two separate problems here. First, the “audiostreamurl” is apparently not being picked up as it reads empty:

---- AA ----
starrating: 90
hdbifurl:
shortdescriptionline2:
shortdescriptionline1: Test MP3 file
contentid: 10031
sdbifurl:
categories: (list of 1)…
List(0)= Paranormal
sdposterurl: http://rokudev.roku.com/rokudev/example … penter.jpg
description: Haunted America Radio Episode 10 - MP3
ishd: false
genre: Paranormal
hdimg: http://rokudev.roku.com/rokudev/example … penter.jpg
streamformat: mp3
length: 7217
contentquality: SD
streamurls: (list of 1)…
List(0)=
runtime: 7217
synopsis: Haunted America Radio Episode 10 - MP3
streamqualities: (list of 1)…
List(0)= SD
sdimg: http://rokudev.roku.com/rokudev/example … penter.jpg
streambitrates: (list of 1)…
List(0)= 1500
hdposterurl: http://rokudev.roku.com/rokudev/example … penter.jpg
audiostreamurl:
title: Test MP3 file
contenttype: episode
hdbranded: false
actors: (list of 1)…
List(0)= Paranormal
contentformat: audio

Second is the parsing error. Here’s is the example xml file that I’ve modified, adding the and as you suggested above.

Ghosts of Deadwood 10031 Talk SD audio mp3 SD 1500 [http://www.hauntedamericaradio.com/audio/Episode10.mp3](http://www.hauntedamericaradio.com/audio/Episode10.mp3) David Soma & Kathleen Lane Paranormal 7217

I’m also not surewhere I’m supposed to drop in the audioplayer code you mentioned earlier. Thanks again for your help.

To get your XML to parse, replace:

<synopsis>David Soma & Kathleen Lane</synopsis>

by:

<synopsis>David Soma & Kathleen Lane</synopsis>