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'.
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.
Yes, the path I get is using the command GETCURRENTDIR$(). I have also tried directly into the Media folder and does not work.
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.
Unfortunately, I think in that sense it's all right.
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.
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.
@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?
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.
Ok, Thank you 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:
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.
That is just too weird. Can you do a simple test code?
Could it be the android phone itself?
Filenames are case-sensitive dont forget
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.
I think this is either related to path and file name or maybe your android machine is a very unusual one.
I´ve heard report of unique android phones not playing music as it should, but it is extremely rare.
It could be something else, the only way to find out is that you post an example code that doesn´t run on android.
Codecs on PC won´t affect android, android should be able to handle ogg by itself I guess.
My example worked fine with v12 and v14 on my win7 64b.
can you show me some piece of code?
Make sure to add GetCurrentDir$() to the load command. Its might require full path. With glbasic own commands only ogg files works. If you using Android Extras commands, which uses own set of commands, then mp3 can also been used as well. That was added as a alternative player for android, which also can fix various issues.
Checkout the Android Extras sample for it. Its mightbeen nicer to create a FUNCTION, so its can use android extras for android and glbasic own for rest.
Im choiced not to integrate the SoundPool rutine to glbasic, due there was few difference, but more can used it as a alternative.
Finally OGG file works. The PLAYMUSIC command is not compatible with SETCURRENTDIR. It is not possible to host the sound files within other folder in Media folder, PLAYMUSIC will not find them.
I want to thank you all for helping me.
ahhh. Nice for pointing and a nice bug.
On Android, anything needs to been in Media folder, because glbasic will auto extract them from APK file to the internal memory, before using. This is happens automatic with Android Extras and in glbasic 14 (which using it).
Actuelly its a bug. Its should have skip the auto extract path, if the file allready exists when full path have been used.
ALso PLAYMUSIC only works with OGG files. If you using SoundPool method, both Ogg and Mp3 can been used.
Thanks for the info,... I don't know about this... :booze: