I'm trying to create a HTML5 page with embedded audio. The page has to work on a ZTE BASE Lutea smartphone (Android 2.1) with Opera Mobile 11. Audio format is MP3 but OGG would be fine, too. All files have to be stored local on the smartphones sdcard.
My problem:
While audio plays fine when loaded from a webserver, it fails when files are local. This is definitely not a source path error. The audio file is preloaded and I can alert the correct audio duration. Then, when the audio play() method is called, it throws me a MEDIA_ERR_DECODE.
This is always the same no matter if I use MP3, OGG or the original WAV file. Any idea why there is a decoding problem of local audio files?
EDIT: When I'm opening a local HTML page "file://localhost/sdcard/index.html" in Opera and the page embeds an audio "http://localhost/audio.mp3", it works. Of course I had to install a local webserver and this would be a very bad solution.
Why is the HTTP protocol needed to play an audio file, does something like a local sandbox exist on android?
EDIT: I found that the Video object is able to play local sounds without problems. Unfortunately it's useless to me because I need an invisible audio and in Opera Mobile there is no way to prevent the video from going fullscreen.
With PhoneGap, you should be able to play local audio.
Opera 12 has the same issue. If the audio is played from cache is not working.
I am using appcache.
This worked on Firefox mobile, so we used that.
Related
I am (at long last) at the very end of a VOD project. It works perfectly, except on Android. Basically, on Android video will not play until the entire video has downloaded. A media server was well out of scope, so we are just serving the videos up from AWS S3. Works fantastically on iOS. Both streaming and downloading the video works exactly as you would expect it to. On Android, it just doesn't seem to want to play before the download finishes. It works well when using a server on the local network (I even see the occasional buffer, so I know it's not just quickly downloading), but nothing remote.
My only guess is that it is to do with the differences in the way iOS and Android stream video. On iOS, video streams via byte-range requests. Every few seconds, it will time itself out and request another range of bytes for the file. On Android, it only sends a single request for the entire file. Not sure how that could be fixed, however.
Does anyone have any tips or pointers here? Any help would be greatly appreciated here.
Happens on Android 4.4 and 4.3.
Using both a remote prod server we own and AWS S3.
AIR 3.9 with Flex 4.11
Utilizing StageVideo and NetStream
Test devices are a Nexus 5 and a Nexus 4
The issue was with the videos themselves. AIR for Android uses the standard approach to streaming where the entire file is requested and it reads it bit-by-bit (as opposed to iOS which requests specific byte-ranges repeatedly).
The problem here is that the player cannot begin playback until the video's metadata has been read. A standard h.264 encode sees the metadata (moov atom) located at the very end of the file, so the video does not begin until the entire video has been downloaded.
Easiest way I have found to fix this is re-encoding the videos through Handbrake with the "Web Optimized" option selected. This will ensure the metadata is located at the very beginning (byte 24, I believe) so the video should begin playing instantly.
Explanation from Adobe
Thread that gave me the idea to use the "Web Optimized" option
AMR narrowband is the default audio encoding for videos captured in Android 2.1
When I upload this to my server and try and view it either in the chrome webbrowser on my mac or streaming from my iPhone it does't play (it does play in quicktime if I copy it locally to my mac)
Is there a way to get this to play? Am I missing a mime-type? It plays fine locally on the android phone in in the android browser.
Server was fine. Turns out the issue is that iOS doesn't support AMR encoding (at least within videos).
Ok, I am lost. I have 2 different streams and can use either one. But neither will work on a webpage PHP or HTML on Android. I've tried using the AUDIO tag for HTML5 and some other Javascript libs. A search of this board hasn't helped me much. Just dead ends.
The Mp3 stream is http://8713.live.streamtheworld.com:80/WWWQFMMOB_SC
The AAC stream is http://5913.live.streamtheworld.com:80/WWWQFMAAC_SC
These are actually inside of .pls files (playerservices.streamtheworld.com/pls/WWWQFM.pls) (MP3 Stream) (playerservices.streamtheworld.com/pls/WWWQFMAAC.pls) (AAC).
I can use any of them on an iPhone, but Android...no luck. It doesn't have to be in the same code as the iPhone player.
Any ideas?? I'm not a pro at code by far, but I'm not bad at adapting, changing and following the logic. Thanks!!
I am unable to consistently play audio files from web pages on my Nexus S (Android 2.3.6). I have six audio files. They're in both mp3 and ogg formats. I have three browsers on the phone that I've experimented with: Browser 2.3.6, Dolphin HD 7.3.0, and Firefox 10.0.2.
All files play every time in Firefox. In Browser and Dolphin, some of the files play and some don't. Each time I test in Browser and Dolphin, the number of files that won't play increase, until finally none or only one plays.
Once, I used Android's Manage Applications tool to delete Browser's data and cache. This also caused the Browser process to stop. This one time, when I restarted Browser and tried to play to audio files, they all played. A subsequent attempt using this method did not restore the ability to play audio.
I also tried to play these audio files from the same web page on desktop computer browsers, Chrome and Firefox. In both cases, all audio files played every time.
Any ideas on what's causing this inconsistent audio playing behavior? Another useful answer would be, is there a way to trap the error (if there is one) Browser gets when it cannot play an audio file.
I'm more of a Java/Server-side programmer, so I'm not very knowledgable about a debug approach for this kind of problem in a mobile browser.
I have a project with a VideoView in it I am streaming a video from online using this method:
mVideoView.setVideoURI(Uri.parse("http://db.tt/ij7w1Nw"));
My videos are mp4 files downloaded from Youtube. I then upload them to my dropbox, that is where the url comes from. This works fine if I download the video and do not make any changes to it, and upload it straight to dropbox. However if I try to make any changes to it for instance convert from .flv to .mp4, or change the size, then I upload it to dropbox it no longer plays in the VideoView. I get a dialog that says 'Unable to play video. Invalid streaming data'. If I take this same exact video and put it on the SD card either manually or even by having my app download it from the url then play it off of the SD card using
mVideoView.setVideoPath(path);
it works fine. I am using Wondershare Video Converter Platinum to do the conversions and size changes.
Is there some sort of specific encoding that is required to stream an mp4 file rather than play it from a local copy? Am I getting this because of some sort of bug/error with wondershare? Has anyone else experienced this type of problem, if so how did you end up fixing it.
Thank you.
The media format guide may help you see what's available. In my experience wrapping a H.264 AVC or MPEG 4-encoded video in a 3GPP container provides the easiest integration. Android is very fickle with both audio and video streaming.