Play sound on Android`s WebView - android

Is there any way to play a sound on Android`s WebView?
audio tag is not implemented

You can use embedded Flash, but it won't work on devices that don't support Flash.
I just had a quick try with Javascript and HTML5 embedded sounds, and they didn't work for me in the Android 2.2 browser, but I may have done something wrong. Hopefully someone will be able to provide a better answer.

You could parse the content for the audio url, download it in the background and start a media player separately.

Related

How to make audio in swiffy HTML5 files play in mobile browsers?

I have taken this problem to various forums, and here once (where was it blocked as off-topic). It seems on-topic to me - a specific programming problem, a software algorithm, and a software tool commonly used by programmers.
I have a website of Flash SWF animations with sound. I converted the SWF to HTML5 using Google's swiffy. On desktop PCs, using Chrome, FF and IE, there is sound, but not in Mobile Safari and Android browsers. And not in Chrome on my iPad.
The audio is embedded in the code generated by swiffy, and it looks like it's MP3 encoded in base64 (see "data:audio/mpeg;base64," and "format":"MP3" in the html).
Since there is no developer forum for swiffy, and I get no replies from the feedback form, I looked around to identify what's stopping Mobile Safari, Android browers and iPad Chrome playing the sound. For Safari, I find things like "You cannot preload sound files" but since the sound is embedded in swiffy, there's no sound file to preload. Why no sound in Android and iPad Chrome, both Google products, is also a mystery.
I imagine there's no hack that will solve the problem, if Google hasn't managed to, but insights are appreciated.
I know it's quite late for you but i think some people may also face the same problem and come to this post. So I would like to offer my answer here
As Victor said, you can use getURL to trigger sound outside. But if I use getURL, I would use Web Audio API in the javascript side. Because using Web Audio API, it is possible to play multi tracks simultaneously in mobile. I intergrated library SoundJS to my project.
However, as you have to change every audio frame into a getURL function, it actually costs you quite a lot of time. I found another optional idea that you can just edit the swiffy core once and for all, which use native audio object (but it also mean you can only play one sound at a time in mobile).
originally, swiffy creates native audio object to play base64 encoded sound. Because of the mobile limitation, it's silent if the sound is not triggered by an input event. However it's possible to reuse an active audio object.
First, I have a button to start the animation,which also create an audio object and play it (with a zero length base64 encoded sound);
audio = new Audio("data:audio/mpeg;base64,");
audio.play();
in swiffy core script, search keyword "new Audio", you will see the part that swiffy plays sound. Instead of createing a new audio object, make swiffy use your old audio object
audio.src = a.sound;
audio.play();
After that, without revising, your swf should be able to play sound even in mobile.
However, as it's quite like a hack. It may get some unexpected problem
You can communicate the swiffy flash with the main HTML file so, inside actionscript, you can send a getURL call to javascript where you have a hidden html5 mp3 player, something like:
getURL("Javascript:playSound();");
In HTML, inside the javascript function, something like:
<audio controls>
<source src="test.ogg" type="audio/ogg">
<source src="test.mp3" type="audio/mpeg">
</audio>
I'm still working in this but I hope this help you.

Cannot play flash in android web view after many try

I am doing an android app which shows my website in the webview. My website contains a flash player for playing movie.
Here is the link which contains the flash player and I want to display on the webview.
After reading many articles, I have tried the following code:
webview2.getSettings().setPluginsEnabled(true);
webview2.getSettings().setPluginState(PluginState.ON);
webview2.getSettings().setJavaScriptEnabled(true);
webview2.getSettings().setAllowFileAccess(true);
But it is still not working.
This may sound very simple, but make sure the platform you're testing this on has the Flash Player installed.
Many android phones do not have flash player in their browsers anymore, and there isnt a flash player plugin for the WebView object.
Your best chance would be to make this video in your page viewed with html5 video tags, or let people view your website in their own browser, which may or may not work (some browsers have flash, some dont)

Play an HLS audio only stream on IOS and Android but keep audio controls

Here the short of it.
I'm using an HLS stream with JWPlayer6 for an iOS/Android app I am working on. JWPlayer http://www.longtailvideo.com/ works well and fallbacks to other streaming and player types gracefully. The problem is this, when I want to securely play back audio only in iOS the player is just a condensed black rectangle with a play icon in the middle if I click on the audio it plays fine but it launches the file in quicktime window, and the quicktime player window completely covers the app so you can't listen to the file and continue to use the app.
Is there any possible way to play an audio only stream that utilizes an actually embed-able player instead of the default mechanism of launching audio media types on iOS and Android.
I have already used JPlayer to achieve the functionality I want by placing the js/css player at the bottom of the app in a fixed position so that you can still browse the app while the file is being played, but this is only demo solution for my boss to show him how it would work, but in the end we will need a solution that can securely stream the audio with a player that lets you keep the controls in-app on the page rather than launching quicktime which even after playing the file does not return you to the apps other views.
Any suggestions would be greatly appreciated.
Lol...anyway finally figured out a solution that works for me in my particular case. Since the html side of things for our application resides in a webview on iOS, thanks to phonegap, I was able to do the following.
HTML5 inline video on iPhone vs iPad/Browser
and now the player finally plays inline just like the iPad. I tested this and it works flawlessly. I also tested it without added the obj-c flag in the app code and it does not work. This means the solution I've provided only works if you are packaging you application using html and obj-c like with phonegap or Titanium etc. This is EXACTLY what I was looking for. Now I can use all of jw's awesomeness and still play nice with iOS and give a great user experience to all of our members...thanks for you time and patience. As a side note the inline audio only player even works flawlessly with Android to write of of the box not java code needed to edit anything. Surprised me because I know how HLS is not really all that well supported yet on the Androids.

Force non-flash Vimeo embed or disable Flash in a WebView?

First some details to help explain:
If you load a Vimeo link such as the following:
http://player.vimeo.com/video/40234826, or use their iframe embed code,
into a WebView, one of two things will happen.
If the device has the Adobe Flash Player app/plugin installed, it will display Vimeo's embedded player. Tapping play, plays the video inline as an embed.
If the device does not have the flash plugin, it will display an image with a play button. Tapping play, opens the Video in a system VideoView. (Because the button links to an mp4 file.)
Since Vimeo's embedded play can be a bit buggy on the vast variety of devices available, I have found that option 2, playing the Vimeo video in an Android media player is a much better experience.
Now the question is, how can I convince the WebView not to use Flash?
I have tried webview.getSettings().setPluginsEnabled(false); but it still loads the flash embed version. How can I trick Vimeo's player into thinking the device does not have flash installed?
Thanks
Update
After further investigating, it seems that setPluginState(PluginState.OFF) works pre honeycomb, but this doesn't work on Honeycomb and ICS.

PhoneGap - Is online video streaming possible?

I have just referred to the PhoneGap Documentation for Media, which stated:
"The Media object provides the ability to record and play back audio files on a device."
I wonder whether video streaming (RTSP) is possible or not with PhoneGap framework? I am trying this out on Android.
Any suggestions highly appreciated.
Yes, streaming to the device is possible.
Just like with a normal website/webapplication.
I don't know if it's done yet, but this is a audio stream script:
http://www.joeldare.com/wiki/play_an_mp3_audio_stream_in_phonegap
I hope that will get you started.
EDIT:
Maby this will also help you to get started:
http://groups.google.com/group/phonegap/browse_thread/thread/584028fe07b0c869/47a1af617c94540a?#47a1af617c94540a
Simply the streaming video can be opened up in a child browser or in App browser to play the video. This solution will work both on Android as well as iOS.
Also if the streaming will be opened in the browser it will appear in full screen mode as q media player will play the video on safari.
Hope this will help.

Categories

Resources