Skip to content

Commit

Permalink
Add delay
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Sep 4, 2022
1 parent ce3f52a commit 92595c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ void loop(){

Further extension examples can be found in the [examples directory](https://github.com/pschatzmann/TinyHttp/tree/main/examples)!


## Documentation

- Here is the generated [Class Documentation](https://pschatzmann.github.io/TinyHttp/html/annotated.html).
- Here is the [Class Documentation](https://pschatzmann.github.io/TinyHttp/html/annotated.html).
- Please also check out the [Information in the Wiki](https://github.com/pschatzmann/TinyHttp/wiki)


Expand Down
5 changes: 4 additions & 1 deletion src/Extensions/ExtensionMusicFileStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tinyhttp {
*/
class ExtensionMusicFileStream : public Extension {
public:
ExtensionMusicFileStream(const char*url="/music", const char* startDir="/", const char* mime="audio/mpeg", const char* extension="mp3", int bufferSize=512, int cspin=-1){
ExtensionMusicFileStream(const char*url="/music", const char* startDir="/", const char* mime="audio/mpeg", const char* extension="mp3", int bufferSize=512, int cspin=-1, int delay=10){
Log.log(Info,"ExtensionMusicFileStream", url);
this->url = url;
this->file_extension = extension;
Expand All @@ -25,6 +25,7 @@ class ExtensionMusicFileStream : public Extension {
HttpStreamedMultiOutput *out = new HttpStreamedMultiOutput(mime, nullptr, nullptr, 0);
this->streaming = new ExtensionStreamShared(url, *out, GET);
this->sd_cs = cspin;
this->delay_ms = delay;

}

Expand Down Expand Up @@ -54,6 +55,7 @@ class ExtensionMusicFileStream : public Extension {
// we just write the current data from the file to all open streams
int len = file.read(buffer,buffer_size);
streaming->write(buffer, len);
delay(delay_ms);
}
}
}
Expand All @@ -71,6 +73,7 @@ class ExtensionMusicFileStream : public Extension {
int loop_limit = 10;
int loop_count;
int sd_cs;
int delay_ms;
bool is_open = false;

void setupSD() {
Expand Down

0 comments on commit 92595c4

Please sign in to comment.