Sub Process_Globals
Public url as String
End Sub
Public Sub Setup
RunNative("setup",url)
End Sub
#if c
#include "M5Atom.h"
#include <WiFi.h>
#include "SPIFFS.h"
#include "AudioFileSourceHTTPStream.h"
#include "AudioFileSourceBuffer.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
AudioGeneratorMP3 *mp3;
AudioFileSourceHTTPStream *file;
AudioFileSourceBuffer *buff;
AudioOutputI2S *out;
//const char * url = "http://192.168.0.6:51042/Basyra%20BCam0004%20Image.mp3";
void setup(B4R::Object* M )
{
M5.begin();
// Serial.printf("this url\n");
//Serial.printf(b4r_main::_url);
Serial.printf("I am in setup\n");
file = new AudioFileSourceHTTPStream(b4r_main::_url);
// Create a buffer using that stream
buff = new AudioFileSourceBuffer( file, 4096 );
out = new AudioOutputI2S();
out->SetPinout(22, 21, 25);
mp3 = new AudioGeneratorMP3();
// Pass in the *buffer*, not the *http stream* to enable buffering
mp3->begin(buff, out);
}
void play(B4R::Object*)
{
if (mp3->isRunning()) {
if (!mp3->loop()) mp3->stop();
} else {
Serial.printf("MP3 done\n");
b4r_main::_playfinished=1;
delay(10);
}
}
#End If