I am new to Roku & Brightscript programming. I want to play music in the background while showing photos from my album in the thumb drive.
I found this awesome project on Github which plays Slideshows. Trying to figure out a way to play music in background. I tried to plug in the audio player into the code.. audio doesn't play.
Here is code addition to the above Github project Newslideshow method I added:
ns.Initialize = init
ns.Show = show_screen
ns.EventLoop = event_loop
ns.PlayMusic = play_music '<-- wired music player
ns.Draw = slideshow_draw
ns.DrawAll = slideshow_drawall
Player Code:
Function show_screen() As Void
m.Screen = CreateObject("roScreen", True)
m.Screen.SetMessagePort(m.Port)
'm.Screen.SetAlphaEnable(True)
m.Compositor.SetDrawTo(m.Screen, m.ScrBkgClr)
m.DrawAll()
m.PlayMusic() '<--Added handler
m.EventLoop()
End Function
Function play_music() as Void
print "music"
m.AudioPlayer = CreateObject("roAudioPlayer")
m.AudioPlayer.SetMessagePort(m.Port)
song = CreateObject("roAssociativeArray")
song.url = "http://lobbytv.azurewebsites.net/api/music/01.mp3/"
m.Audioplayer.addcontent(song)
m.Audioplayer.setloop(false)
m.AudioPlayer.play()
'm.EventLoop()
End Function
Any help is appreciated.
Most likely, it cannot resolve stream format. Try setting it:
song.streamFormat = "mp3"