Bladeren bron

Minor improvements to MP3 Player example

main
PaulStoffregen 8 jaren geleden
bovenliggende
commit
682687ccb9
1 gewijzigde bestanden met toevoegingen van 10 en 2 verwijderingen
  1. +10
    -2
      examples/MP3Player/MP3Player.ino

+ 10
- 2
examples/MP3Player/MP3Player.ino Bestand weergeven

// Simple MP3 file player example // Simple MP3 file player example
// //
// https://forum.pjrc.com/threads/27059-MP3-Player-Lib-with-example?p=101537&viewfull=1#post101537
//
// Requires the prop-shield and Teensy 3.2 or 3.1 // Requires the prop-shield and Teensy 3.2 or 3.1
// This example code is in the public domain. // This example code is in the public domain.


#include <Audio.h> #include <Audio.h>
#include <Wire.h> #include <Wire.h>
#include <SPI.h> #include <SPI.h>
#include <SD.h>
#include <SerialFlash.h> #include <SerialFlash.h>
#include <play_sd_mp3.h> // https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib #include <play_sd_mp3.h> // https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib
//#include <play_sd_aac.h> //#include <play_sd_aac.h>
} }
} }


//Set Volume
mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);

//Start Amplifier //Start Amplifier
pinMode(PROP_AMP_ENABLE, OUTPUT); pinMode(PROP_AMP_ENABLE, OUTPUT);
digitalWrite(PROP_AMP_ENABLE, HIGH); // Enable Amplifier digitalWrite(PROP_AMP_ENABLE, HIGH); // Enable Amplifier


void playFile(const char *filename) void playFile(const char *filename)
{ {

SerialFlashFile ff = SerialFlash.open(filename); SerialFlashFile ff = SerialFlash.open(filename);
Serial.print("Playing file: "); Serial.print("Playing file: ");
Serial.println(filename); Serial.println(filename);
playMp31.play(pos,sz); playMp31.play(pos,sz);


// Simply wait for the file to finish playing. // Simply wait for the file to finish playing.
while (playMp31.isPlaying()) {}
while (playMp31.isPlaying()) {
yield();
}
} }





Laden…
Annuleren
Opslaan