[SOLVED] Problems playing ogg and mp3 on android

Previous topic - Next topic

msx

I can not to play ogg and mp3 files on Android, I tried directly with the Playmusic command and using the latest version of AndroidExtras, with music.play and none works. Using Check_asset not work either.

I think that might not be properly locating the file. I checked the location and is as follows: /data/data/com.company.title/files/Media/audios/file.ogg,
however I can not find this location on my tablet.

After loading the ogg file with music.play I check Music.getDuration () and responds me '-1'.

Ian Price

Yeah, it's most likely a path issue - have you tried to set the directory just to the Media dir? Or used GetDirectory (or whatever it is) to obtain the current dir? Try those. The try to load the sound without all the extra gubbins you have listed "/data/data.." etc.
I came. I saw. I played.

msx

Yes, the path I get is using the command GETCURRENTDIR$(). I have also tried directly into the Media folder and does not work.

Ian Price

Are you sure that the file is 100% matching, including format. Android is very specific. Ensure that your file is named EXACTLY what you are looking for. eg LOADMUSIC "fred.ogg" won't load "fred.OGG" or "FRED.OGG" etc. Case sensitivity is really important.
I came. I saw. I played.

msx

Unfortunately, I think in that sense it's all right.

spacefractal

use full path to load it.

Does you use AndroidExtras or glbasic own. They dont share the same commands. That one in music. using a alternative way to play the music.

You might can do a DOESFILEEXISTS() first for checking the file exists or not, before loading.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

erico

Hello MSX,

check this thread out see if it helps you out:
http://www.glbasic.com/forum/index.php?topic=9933.0

Your problem could be path or the ogg format/compression.

msx

#7
@spacefractal

I have tried both ways and nothing works.

DOESFILEEXISTS() responding 1

@erico

I think it may indeed be coding problem but I can not find the appropriate parameters and software that allows me to re-encode it correctly.



P.D.: Can you attach an ogg file that works on android?

erico

I did a test a while ago lost over one forum post I can´t find.
It was done on a >v14 GLB version.
I have the ogg file here and will give a try on android soon. It is 11mb. worked fine on android before, not on pc.
I will give a try and let you know.

msx


erico

Here we go, just tested OGG on android running latest GLB14.
All is fine and works as expected.

The program you may want to use for such conversions is AUDACITY, it works perfectly and can be found here:
http://www.audacityteam.org/
It is hard to beat this tool soundwise. :)

As for file properties:
encapsulator: OGG
codec: Vorbis Audio (vorb)
sample rate: 44100hz (48K should work fine too)

Here a wetransfer of the ogg music I just used for testing:
https://www.wetransfer.com/downloads/f886f504faf21e0824f8ceebd13e74c520160623155649/91cbba4772a3c2f8ec2fb556622cf1e720160623155649/4db790

Cheers :good:

msx

Music doesn't play on Android still. I tried your OGG file and does not play. Tested with PLAYMUSIC command and using Android Extras. The Play command of AndroidExtras apparently loads the file correctly because getDuration () responds well.

I installed the vorbis audio codecs on Windows 10. I use the latest version of GLB and Android Extras.

I do not know what else I can try.

erico

That is just too weird. Can you do a simple test code?
Could it be the android phone itself?

MrTAToad

Filenames are case-sensitive dont forget

msx

#14
I tried to compile an application which worked on android and GLB 12 and now does not work in GLB 12 and 14. The only thing different I think is the operating system because I upgrade to Windows 10. It could be a problem of codecs but I installed K-Lite Codec Pack and everything remains the same.

MP3 work in win32 but not the OGG. Android none.