Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Program : Music launcher app
- --- Author : LightKnight51
- --- last modification : 18/04/2023
- --- (In editing ...)
- --- Utils API
- os.loadAPI("MarquitoLuaUtils")
- -- Music launcher program
- function RunMusicLaunch()
- local dfpwm = require("cc.audio.dfpwm")
- -- Find the speaker
- local speaker = MarquitoLuaUtils.FindSpeaker()
- print("Please enter a valid url for download an audio file")
- local audioUrl = nil
- while audioUrl == nil do
- audioUrl = tostring(read())
- end
- local fileName = "MusicTest"
- MarquitoLuaUtils.DownloadAndGetAudioFile(audioUrl, fileName)
- local decoder = dfpwm.make_decoder()
- LaunchMusic(dfpwm, speaker, fileName)
- end
- -- Launch new music
- function LaunchMusic(dfpwmLib, speaker, musicFileName)
- local dfpwm = require("cc.audio.dfpwm")
- local decoder = dfpwm.make_decoder()
- for chunk in io.lines("/data/audio/" .. musicFileName .. ".dfpwm", 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- end
- RunMusicLaunch()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement