Rookai
2 years agoBinge Watcher
Accessing local (tmp:/) audio files to be played by roAudioplayer
Hi,
I have a local mp3 audio file stored in tmp:/ ("tmp:/audio.mp3), and this file is generated from response of an API call " AsyncPostFromFileToFile " . I would like to play it using roAudioPlayer component. When I pass it to roAudioPlayer, it does not play anything; where it plays from an external URL perfectly. This is my script:
' Create the roAudioPlayer object
        wavFilePath = "tmp:/audio.mp3"
        audioPlayer = CreateObject("roAudioPlayer")
        port = CreateObject("roMessagePort")
        audioPlayer.SetMessagePort(port)
        ' Create the associative array for the audio content
        song = CreateObject("roAssociativeArray")
        song.url = wavFilePath
        file = CreateObject("roFileSystem")
        print file.GetVolumeList() 
        print file.GetDirectoryListing("tmp:/") 'tmp:/audio.mp3 exists
        ' Add content to the audio player and start playback
        audioPlayer.addcontent(song)
                ' urlPath = "file://" + wavFilePath
                ' print "urlPath: "; urlPath
        'urlPath = "http://www.sdktestinglab.com/Tutorial/sounds/audionode.mp3"                
        'audioPlayer.setcontentlist([{ url: urlPath }]) ' works when tried individually
        'audioPlayer.addcontent(song)
        audioPlayer.setloop(false)
        audioPlayer.play()
        print "Audio playback triggered for file: " + wavFilePath
        ' Event loop to handle audio player events
        while true
            msg = wait(0, port)
            if type(msg) = "roAudioPlayerEvent"
                if msg.isStatusMessage()
                    print "roAudioPlayerEvent: "; msg.getmessage(); msg.getindex()
                    if msg.getmessage() = "end of playlist"
                        exit while
                    end if
                end if
            end if
        end while
This is the consul log for this section (please note I require msg.getindex() for each message to monitor progress; for URL-based mp3 file, it goes 0 to 1000):
roAudioPlayerEvent: prebuffer started 0
roAudioPlayerEvent: startup progress 0
roAudioPlayerEvent: startup progress 66
roAudioPlayerEvent: startup progress 132
roAudioPlayerEvent: startup progress 198
roAudioPlayerEvent: startup progress 264
roAudioPlayerEvent: startup progress 330
roAudioPlayerEvent: prebuffer done 0
roAudioPlayerEvent: startup progress 330
roAudioPlayerEvent: prebuffer done 0
roAudioPlayerEvent: startup progress 330
roAudioPlayerEvent: Content contains no playable tracks. 0
roAudioPlayerEvent: end of playlist 0
Answers like following suggest the local path can be fed to roURLTransfer by using prefix "file://", but I had no luck trying it:
What am I doing wrong? What should I change to make this work? Any help will be appreciated.