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

Audio play code does not support on firmware version 3.1

Hi
My audio play code does not play on video on roku firmware version 3.1 . It is playing correctly on version greater than 3.1
Here is my code:-
Function showAudioItemDetail(videoIndex as Integer,json As Object) As Void
print "play audio funtion started"
port = CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
audio = CreateObject("roAudioPlayer")
screen.SetMessagePort(port)
audio.SetMessagePort(port)
item=getAudioItemDetail(videoIndex, json)
song = CreateObject("roAssociativeArray")
adjective=item.StreamUrls
print "video url ";item.StreamUrls[0]
pauseStatus = 0
song.url = item.StreamUrls[0]
'song.url = "http://ia700601.us.archive.org/10/items/HindiPravachanMp3-ByShriShankaracharyaJi/12-SIDE-A.mp3"
print "my url ";song.url
song.streamformat="hls"
bitrates = [10240]
song.StreamBitrates=bitrates
print "==>";item.StreamUrls
screen.SetContent(item)
screen.AddButton(1,"Play")
screen.AddButton(2,"Go Back")
screen.SetStaticRatingEnabled(false)
screen.AllowUpdates(true)
screen.UseStableFocus(true)
audio.addContent(song)
audio.setloop(false)
screen.Show()
while true
msg = wait(20000, screen.GetMessagePort())
if type(msg) = "roSpringboardScreenEvent"
if msg.isScreenClosed() then
exit while
else if msg.isButtonPressed()
if msg.GetIndex() = 1
if pauseStatus = 0
'audio.Seek(10000)
audio.Play()
screen.ClearButtons()
screen.AddButton(1,"Pause")
screen.AddButton(2,"Go Back")
screen.Show()
pauseStatus = 1

else if pauseStatus = 1
audio.Pause()
screen.ClearButtons()
screen.AddButton(1,"Play")
screen.AddButton(2,"Go Back")
screen.Show()
pauseStatus = 2

else
audio.Resume()
screen.ClearButtons()
screen.AddButton(1,"Pause")
screen.AddButton(2,"Go Back")
screen.Show()
pauseStatus = 1
end if
else if msg.GetIndex() = 2
exit while
end if
endif
endif
if type(msg) = "roAudioPlayerEvent"
if msg.isStatusMessage()
print "Message = ";msg.GetMessage();" get index ";msg.GetIndex()
if msg.GetMessage() = "end of playlist"
screen.ClearButtons()
screen.AddButton(1,"Play")
screen.AddButton(2,"Go Back")
screen.Show()
pauseStatus = 0
end if
else if msg.isStreamStarted() then
print "Straem Started";msg.GetIndex()

else if msg.isRequestFailed() = true
print "Audio playback failed due to an error.";msg.GetMessage()


endif
endif
end while
print "show audio function end"
End Function


'***********************************************************
'**
'** getAudioItemDetail()
'**
'** This function returns an object of roAssociativeArray
'** of Content MetaData for roSpringboardScreen
'***********************************************************


Function getAudioItemDetail(videoIndex as Integer, json as Object) as Object

print "getItemDetail started"
print "url =>";[json.video[videoIndex].url]
print " => ";json.video[videoIndex].thumbnailUrl
item = {
ContentType:"episode"
Title:json.video[videoIndex].title
SDPosterUrl:json.video[videoIndex].thumbnailUrl
HDPosterUrl:json.video[videoIndex].thumbnailUrl
Description:json.video[videoIndex].Description
StreamUrls: [json.video[videoIndex].url]
}
print "getItemDetail ended"
return item
End Function




Plz help me to find which code is not working correctly for this version(3.1)
And plz help me to get out of this problem

Thanks
Deepak Gupta
0 Kudos
1 REPLY 1
RokuJoel
Binge Watcher

Re: Audio play code does not support on firmware version 3.

I could be wrong but it is more likely that the .mp3 file is not in HLS format, and you have the stream format set to "hls". Try "mp3" as the stream format and see if that works. Also, since you don't provide the source URL (unless the commented out URL is the url you are testing) we don't really have a way to know if the issue might be the audio file itself. The newer devices can stream a wider range of audio formats.

- Joel
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.