Simple question:
I'm using MediaPlayer to play mp3 files (they play just fine), but also i need support for WMA files. I know some devices support it, but not all of them, but i want some way where I'm sure it will play in any device. Is there anything i can implement or do so i can play Mp3 and WMA files?
right now i got two test buttons, with the same code, one the source is an Mp3 (works) the other same code with a wma (fails)
MediaPlayer mp = MediaPlayer.create(this, Uri.fromFile(source));
mp.start(); // no need to call prepare(); create() does that for you
Thanks.
Alex
Why don't you reencode the wma file to mp3 or ogg (preferentially)? wma is a closed format and it's support depend on some libraries not always available on Android devices, and they're not part of the AOSP tree itself. That being said, most AOSP derived ROMs wont play wma's.
So the best thing to do is to reencode the files to ogg or mp3.
Related
I have splash videos, .swf files I want to run in VideoView instead of running in WebView. Is it possible to play .swf in VideoView android, if possible please provide the solution
No.
A SWF file is short for Shockwave Flash. It is a compiled runtime Flash file and requires a plugin or supported library set.
It is not a video file.
If it plays on the Android at all, it would be because you somehow found a Flash plugin that would work on your system.
What you CAN do, however is convert the file to an MP4 that CAN be played as you intend. There are online services for this.
But many don't support audio. And many of the free ones won't do anything longer than 2 minutes or so.
Is it possible to play .swf in VideoView android
No. That is not a supported media format.
I'm trying to play a couple of short audio files (ca. 2sec) in an Android App with the Media Player. They do play, but for some of them I get a click sound at the end (which differs from file to file).
There are no click-sounds when I play it on the PC, also I tried to convert it from .mp3 in .ogg and modified the soundfiles themselves, nothing helps, I think the problem is probably the Media PLayer.
For short audio files, like sound effects, I would use a SoundPool
Also see this question and answer here: The correct way to play short sounds Android?
I need to play multiple audio track at a time from sd card. I was trying to play with SoundPool. But it does not support larger files.
I tried with AudioTrack but it needs pure PCM code. PCM code generation bit of complex from mp3 or 3gp file, as android do not have anything build in to that.
I've look OpenSL Engine, But did not find any good example or tutorial to work with it.
How can I play multiple audio at a time in loopy style? any idea, suggestion would be great a help.
I want to play in .mov file in android. But videoview or mediaplayer doesn't support this meida format. How can i add the support to it?
In general Android doesn't support any other media formats than the one listed here. That being said, there are quite a few 3rd party players that enable playback of more exotic formats, most of which are probably based around ffmpeg. You might want to take a look at the open source Dolpin Player (actual player also available in the Play store) for Android for some more pointers - not sure if mov playback is supported by default though.
However, since most mov files are actually H.264 encoded these days, why not remultiplex (or re-encode, depending on the source) into an something that Android plays nice with, e.g. an mp4 container? In terms of video support on Android, H.264 is definitely the way, as also pointed out by the 'Video Encoding Recommendations' section in the earlier link.
I know this is an old question, but times changin'
Now we can use the ExoPlayer as a custom Video Player (like VideoView), it supports more formats than the VideoView on android.
It's really simple to use, just to play videos, but has the powerfull of customization if you needed.
https://google.github.io/ExoPlayer/
Give it a try and please respond if this helped you.
Just try to play it anyway. The Quicktime .mov specification is the predecessor of the MP4 spec. There are only differences in a few atoms/boxes. You will be able to play an MP4 as .mov and a .mov as MP4 in most cases.
I found that even the big named players such as MX Player, BS Player and VLC for Android would not play .mov files correctly, especially those that had been recoreded on my wifes iphone 4s.
The playback was very choppy on my Nexus 7 and Nexus 10 and totally unwatchable on my HTC One (M7).
The player I found and installed that will play old and new iphone movie clips (.mov) flawlessly was found freely available from the Google Play Store.
Here is the best player I have found and believe me I have tried lots:
Playing .MOV files on an Android Device
Hope this helps some of those people with an Android device wishing to view iphone .mov files.
I know we can play mp3 file in MediaPlayer.
But can we play mp3+g on android??
I saw in the documentation on android, but i didn't see it.
http://developer.android.com/guide/appendix/media-formats.html
Is there any work around or library to do this?
Thanks
I don't "think" that Android is going to support mp3+g playback anytime soon. That being said an mp3+g "file" should either be one zipped file(with two files inside) or two separate files named the same with exception of the file extension. So other then playing the MP3 there is really nothing else that MediaPLayer can do, and changing MediaPlayer int the android framework to get this to work would not be portable from device to device.
Workaround 1
Use FFMPEG to transcode and mux these files to a different format that is supported such as mp4. Here is an example of someone using ffmpeg to mux mp3+g into FLV.
Workaround 2
Another option would be to use Android For VLC which is in pre-alpha found here. Now I'm not sure that VLC for android will support mp3+g, but libvlc does support decoding of the two files so I'm guessing it would work, or you could alter the code a bit to get it to work. I have checked out the VLC for Android code recently and I have to say its a cpu hog but since mp3 and cdg are generally smaller less cpu intensive files I think that android devices could handle the work load using VLC.
Workaround 3
Now as far as more complex options you could utilize the Android NDK and create a decoder yourself (This would take you a lot of time).
Hope some of this helps you.
I have found the solution..
http://code.google.com/p/cdg-toolkit/
It was written in java so we should porting it first to Android if you want to use it.