Author Topic: Android: Play BASS stream or music from Assets with JNI  (Read 286 times)

Raptisoft

  • Posts: 28
I noticed that there is a Java wrapper called BASS.Asset to help with StreamCreateFile or MusicLoad.

In my case, I'm working in C++.  Google HAS, finally, added a C++ wrapper for reading assets.  JNI now has functions that mimic normal file read/write operations (see here: https://developer.android.com/ndk/reference/group/asset).

Is there a C++ equivalent of BASS.Asset that will route through those functions?

Ian @ un4seen

  • Administrator
  • Posts: 22244
BASS does actually use those function internally for the BASS.Asset class. AAsset_openFileDescriptor is used to get a file descriptor that can be used with the normal file functions (eg. read). If you would like to do the same yourself in C/C++ code, you can do so with BASS_StreamCreateFileUser. Another option is to load the file to memory and pass that to BASS_StreamCreateFile (or BASS_MusicLoad).

Raptisoft

  • Posts: 28
Thanks for the quick reply!  I kludged it all together as a proof of concept by pulling it into memory, but that increases load time and memory usage so I was hoping to stream it right from the file.   I'll see what I can do with BASS_StreamCreateFileUser!