Some mp3 files are not played

Started by Alex5152,

Alex5152

Hello,

Unfortunately I got an audio file that is not played.
Here is the link to 2 files from the same audiobook:
https://drive.google.com/drive/folders/1vnbuW5d1iW5wKlFByjl_HIwQybqXfjlG?usp=drive_link

"06 - The Way Of Kings.mp3" - can't play.
"13 - The Way Of Kings.mp3" - perfectly fine.

If you have time - please look in this issue.

Thank you!

Chris

#1
06 - The Way Of Kings.mp3 will have a wrong File Extension.
Its not a mp3 its a AAC File.

The AAC/MP4 format is supported as standard by BASS via the OS's codecs on macOS and iOS (also Android 5 and Windows 7 and updated Vista).
On which operating system do you work ?
Another possible way is to load it via the Bass_AAC Addon.

https://www.un4seen.com/bass.html#addons
https://www.un4seen.com/doc/#bass/BASS_PluginLoad.html

Alex5152

I'm on Android.

I have this in my code:
BASS.BASS_PluginLoad("libbass_aac.so", 0)

The file is perfectly opened by:
ParcelFileDescriptor parcelFileDescriptor = context.getContentResolver().openFileDescriptor(fileUri, "r");
mBassDecodeChannel = BASS.BASS_StreamCreateFile(parcelFileDescriptor, 0, 0, BASS.BASS_STREAM_DECODE);

Then the following code returns true
BASS.BASS_ChannelPlay(mBassChannel, true)

But no playback happens.


Alex5152

BASS.BASS_CHANNELINFO ci = new BASS.BASS_CHANNELINFO();
BASS.BASS_ChannelGetInfo(mBassDecodeChannel, ci);

// Here is the simplified version of streamProc
BASS.STREAMPROC streamProc = (handle, buffer, length, user) -> {
                        int r = BASS.BASS_ChannelGetData( mBassDecodeChannel, buffer, buffer.capacity() );
                        return r < 0 ? BASS.BASS_STREAMPROC_END : r;
}

mBassChannel = BASS.BASS_StreamCreate(ci.freq, ci.chans, BASS.BASS_STREAM_DECODE, streamProc, null);

Chris

QuotemBassChannel = BASS.BASS_StreamCreate(ci.freq, ci.chans, BASS.BASS_STREAM_DECODE, streamProc, null);
Just remove the flag "BASS.BASS_STREAM_DECODE"

Alex5152

I have replaced code with this and it still don't work on "06 - The Way Of Kings.mp3" file.
ParcelFileDescriptor parcelFileDescriptor = context.getContentResolver().openFileDescriptor(fileUri, "r");
mBassChannel = BASS.BASS_StreamCreateFile(parcelFileDescriptor, 0, 0, 0);

"13 - The Way Of Kings.mp3" works perfectly fine.

Chris

On which Android Version?
Another way to locate the error just place a BASS_ErrorGetCode() Call
directly after the BASS_StreamCreateFile Call.

Alex5152

I have tested this on Android 12, 14, 16.

BASS.BASS_ErrorGetCode() always returns 0.

radio42

Have you tried to rename your file to .m4a or .aac?

Are you sure the bass_aac add-on was loaded successfully?

And where in your code do you play the file?

Alex5152

//Have you tried to rename your file to .m4a or .aac?
Yes.

//Are you sure the bass_aac add-on was loaded successfully?
Yes.

//And where in your code do you play the file?
Here is the test app:
https://drive.google.com/file/d/1Dn8FI251siDdYNNPZ4CMGHrovKwOYHCQ/view?usp=drive_link

To test it you must copy audio file to "/data/data/com.example.myapplication" folder on your phone.

Thank you!

Alex5152

I noticed that if I don't load "libbass_aac.so" plugin (as in the code below) then the file is played fine!

BASS.BASS_Init(-1, 44100, 0)
//if ( BASS.BASS_PluginLoad("libbass_aac.so", 0) != 0) {
    //val path = "/data/data/com.example.myapplication/06 - The Way Of Kings.aac"
    val path = "/data/data/com.example.myapplication/06 - The Way Of Kings.mp3"
    //val path = "/data/data/com.example.myapplication/13 - The Way Of Kings.mp3"
    val handle = BASS.BASS_StreamCreateFile(path, 0, 0, 0)
    BASS.BASS_ChannelPlay(handle, true)
//}

Ian @ un4seen

Both of those files appear to be in MPEG-TS format, which is what's usually used in HLS streams. BASSHLS also supports MPEG-TS files outside of HLS streams, so you should be able to play them if you load BASSHLS via BASS_PluginLoad first. Note that the length won't be available though and seeking won't be possible.