Time for action – playing background music
Let's open and play an MP3 music file with OpenSL ES:
- MP3 files are opened by OpenSL using a POSIX file descriptor pointing to the chosen file. Improve
jni/ResourceManager.cpp
created in the previous chapters by defining a new structureResourceDescriptor
and appending a new methoddescriptor()
:... struct ResourceDescriptor { int32_t mDescriptor; off_t mStart; off_t mLength; }; class Resource { public: ... status open(); void close(); status read(void* pBuffer, size_t pCount); ResourceDescriptor descriptor(); bool operator==(const Resource& pOther); private: ... }; #endif
- Implement
jni/ResourceManager.cpp
. Of course, makes use of the asset manager API to open the descriptor and fill aResourceDescriptor ...
Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.