I've been trying to get this function working for weeks now and still no dice. At the most basic level I want to stop the current background playback (if already playing), load up an mp3 from a specified path, and play the mp3.
I've read through all of the plugin.h file as well as its subsidiary plugins that use that mp3_play_data function. I load the contents of the mp3 to a variable just fine(Its a small mp3 of about 92kB so memory overflow shouldn't be a problem). Then I feed the contents of that variable into the first argument of the mp3_play_data function along with a file size of what I've measured the file to be.
Most of the time it comes up with an error saying:
attempt to call field 'mp3_play_data' (a nil value)
/MusicTest.lua:76: in main chunk
or on rare occasions it just ignores the function altogether.. -_-
Here's my code so far, I used some of the helper funcs from helloworld.lua to load the mp3 contents into memory:
--Test the sound playback commands
track = "/test.mp3"
-- Helper function which reads the contents of a file
local file = io.open(filename, "r")
if not file then
local contents = file:read("*all") -- See Lua manual for more information
file:close() -- GC takes care of this if you would've forgotten it
printf("Test to play sample MP3")
rb.mp3_play_data(file_get_contents(track), 98304, nil)
while rb.mp3_is_playing() do
BtnInput = rb.get_action(rb.contexts.CONTEXT_STD, rb.HZ)
until BtnInput == rb.actions.ACTION_STD_OK
Any help is appreciated