Hi all,
Is it possible to select a resource from this array in the BinaryData namespace ?
I am trying to figure out how to play an mp3 by passing a number to an array of resources.
Do I need to initialize an array in the constructor or can I just do something like this?
void playfile(const void * sourceData, size_t sourceDataSize)
{
AudioFormatReader* reader = formatManager.createReaderFor( new MemoryInputStream(sourceData, sourceDataSize, false));
if (reader != nullptr)
{
ScopedPointer<AudioFormatReaderSource> newSource = new AudioFormatReaderSource (reader, true);
transportSource.setSource (newSource, 0, nullptr, reader->sampleRate);
playButton.setEnabled (true);
readerSource = newSource.release();
}
if (reader == nullptr)
{
playButton.setEnabled (false);
}
transportSource.setPosition (0.0);
changeState (Starting);
}
int main()
{
int note = 1;
playfile(BinaryData::getNamedResource(BinaryData::namedResourceList[note]));
}
Any replies from this JUCE and C++ newbie would be greatly appreciated …
Sean