简体   繁体   中英

How can MP3 files without a file extension play in the Android files app and is there any way I can play such files in my MP3 player Android app?

I am creating an MP3 Player app. It's mostly working correctly but there is one edge case.

If a user has a file named "Bieber.mp3" but changes the name of the file to "Bieber" without the file extension in the files app (on Android), they will still be able to play the song properly from the files app depending on the device (older devices like Nexus running on marshmallow will do it while newer devices like the pixel on Android 12 will say it's an invalid file type).

However, when the MP3 file is emailed (or uploaded somewhere in the cloud like drive or Dropbox), the file will have an unknown file type when attempting to from there

I want to know, how can MP3 files that are renamed to exclude the.mp3 extension still play in the android files app? Is there any way I can check to see if a file without the.mp3 extension is still an audio/mp3 file in Java for my mp3 player?

If mp3 files without the mp3 extension can play in the android files app, surely there should be some way to play/access them in the MP3 player I'm making, right?

Well, Android has this library/class called MediaPlayer :

https://developer.android.com/guide/topics/media/mediaplayer

The MediaPlayer is what you use when you play audio,

the MediaPlayer takes the input(the file) as long as it is still encoded as an audio file.

No matter what you do with the file extension, as long as it is still encoded as audio,

it will stay as an audio file.

That's why~

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM