i am trying to load a webpage on a web view where the page has a video in it. i am able to load the web page on the web view but the video is not playing and the audio is heard. this is the link i m loading to a web view.
http://html5videoformatconverter.com/html5-video-tag-example.html
and all i m doing is
public class VideoActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView mWebView = (WebView) findViewById(R.id.wvVideo);
mWebView.setWebChromeClient(chromeClient);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("http://html5videoformatconverter.com/html5-video-tag-example.html");
}
private WebChromeClient chromeClient = new WebChromeClient(){
#Override
public void onShowCustomView(View view, CustomViewCallback callback) {
// TODO Auto-generated method stub
super.onShowCustomView(view, callback);
if(view instanceof FrameLayout){
FrameLayout frame = (FrameLayout)view;
if(frame.getFocusedChild()instanceof VideoView){
VideoView video = (VideoView)frame.getFocusedChild();
frame.removeView(video);
video.start();
}
}
}
};
}
pls help me modify my code. thanks
Android Browser and WebView has many known problems playing HTML5 <video> videos.
Android webview cannot render youtube video embedded via iframe
Unless you can target Android 4.0 or good modern firmwars, the current workaround is to have a thumbnail image link to a video and then this link opens the video in the native Android video player.
For more information with HTML5 video problems on Android please feel free to search stackoverflow.com.
This worked for me, problem was to do with file permissions on the locally stored video. Hope it helps!
<video width="365" height="200" src="/mnt/SDcard/media/video/abc.mp4" controls autobuffer></video>
As #Mikko says, this is a tricky area.
One thing to check is that you have hardware acceleration enabled. I encounter the exact same symptoms the OP describes when leaving it turned off.
You can enable it at the application or at the activity level:
<application
android:icon="#drawable/icon_72"
android:logo="#drawable/icon_menu_72"
android:label="#string/app_name"
android:hardwareAccelerated="true"
>
OR
<activity
android:name=".MyActivity"
android:hardwareAccelerated="true"
>
When I encountered this problem it was due to the compression type. For android I had to use base profile compression rather than high profile compression. ffmpeg compatibility has a description.
I answered a similar question here.
I was converting my mobile website with youtube embeds into android app....this project helped me get rid of getting the video to fullscreen in webview. All my problems were solved. You can get something from here.
https://code.google.com/p/html5webview/
Related
I am new to android platform, and I want create simple
thats play videos from web via iframe
but the result is horrible ... very very bad
even the user can't watch in full screen
and the size of video is very big,, bigger then webView?
so, if any one know a good way to play video.. with iframe in android, please tell me..
i have tested the code on iOS it's works prefect... so the problem is android...
here's my Code
String hrmlCode = "<center>" +
"<iframe type=\"text/html\" frameborder=\"0\" scrolling=\"yes\" width=\"367\" height=\"320\" src=\"http://video.com/WqPOh.php?get=vid394g5\" allowFullScreen></iframe>" +
"</center>";
CWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
act.setProgress(progress * 1000);
}
});
CWebView.getSettings().setJavaScriptEnabled(true);
CWebView.getSettings().setPluginState(PluginState.ON);
CWebView.loadData(hrmlCode, "text/html", "UTF-8");
thanks in advance
This is a very famous issue in android. The iframe just doesnt work as expected and it is very buggy.
I would say you don't include but simply provide a thumbnail of the video which directly links to your video file
Look into the earlier solution below
https://github.com/droid28/VimeoVideo
Google Reader-esque optimizing of WebViews on Android
I'm hoping someone can set the record straight for me. I know there are several posts about this issue, but I'm still unclear about this.
I want my application to show an image of a page out of a book, and inside that image I want to play a youtube video. Apparently, I"m supposed to use a WebView for this.
WebView mWebView = new WebView(this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.setWebViewClient(new HelloWebViewClient());
setContentView(mWebView);
String Play = "<iframe width=\"600\" height=\"400\" src=\"http://www.youtube.com /embed/VCDOjdYhj1Y\" frameborder=\"10\"</iframe>";
mWebView.loadData(Play, "text/html", "utf-8");
}
private class HelloWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
When I do this, the video looks okay but the sound is lagging. It's very noticeable if someone is talking because the words don't match their lips. From what I understand, WebView really isn't meant for showing video even though it's supported. It's simply a way of showing a web page inside of the app with preferably no user interaction. If you want video and web pages, you're supposed to launch the browser with an Intent. I don't want to do this. I can't use a VideoView because I'm not pointing directly to a video file.
So is that it? Am I out of options? You'd think Youtube and Android would be very compatible since their both Google. Embedding a youtube video in an HTML View works really well in iPhone apps. I hope someone can give me the final word on this. Thanks!
Can't it is something with how the url is loaded like parents, etc.
I’m trying to display a page of embed YouTube videos. I got the code from YouTube website. The page gets displayed correctly when I load it up in the browser but on my embedded web page the YouTube videos do not show the first frame. Its just a black box with the YouTube logo on the bottom. If you click on it, it does play the video. I tread to enable java script, still did not work.
public class cVideos extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videos);
WebView mWeb=(WebView) findViewById(R.id.webvideo);
mWeb.getSettings().setJavaScriptEnabled(true);
mWeb.getSettings().setJavaScriptEnabled(true);
// mWeb.loadUrl("http://www.besttechsolutions.biz/projects/bigbiz/mobvideo.php");
mWeb.loadUrl("http://www.besttechsolutions.biz/projects/bigbiz/videored.php");
}
}
Try embedding &autoplay=1 in the src attribute of the iframe tag in the page source.
Even so, autoplay will not work on Android 2.1 devices, as they cannot support HTML5 video in the browser.
I am using the following data to display in a WebView. These are the HTML tags along with
the iframe which is referring to a video.
Now the problem is when I click on it, it shows the play button but cannot play the video.
Can I play this video inside WebView or not?
<p></p><P> because of Jon’s pro-growth, business-friendly policies, Utah's economy expanded at more than triple the national rate and was named the best state for business by <EM>Forbes.</em><BR /><BR /><IFRAME height=241 src="http://player.vimeo.com/video/25349114" frameBorder=0 width=425></iframe></p><br />
<P>America needs a dose of the same medicine. Today, our nation has the second highest corporate tax rate in the developed world. We have convoluted and confusing regulations.
<!--break--><!--break--><p></p>
when I try to run this url in the android browser it opens videoview and plays that file perfectly but why not in iframe?
http://player.vimeo.com/video/25349114
The key thing is to enable browser plugins.
// how to enable the webview plugin changed in API 8
if (Build.VERSION.SDK_INT < 8) {
mWebView.getSettings().setPluginsEnabled(true);
} else {
mWebView.getSettings().setPluginState(PluginState.ON);
}
Also worth checking flash player is installed
WebView wv;
wv = (WebView) findViewById(R.id.mywebview);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setPluginsEnabled(true);
Use this code to load your video and also update the flashplayer of your device...
There is one HTML page, streaming a music file and It's working on window but i need to run this html file on android.
also i need to control all the feature of music by javascript function e.g. play,pause,stop, volume up & down.
Can someone give me any idea?
Note : i am new to android but good hand in java. Just going through android tutorial and i came to know this feature can be done using webview. is it ?
Its not clear from the post if its a requirement that you have to play it on a html page or you just want to play the .mp3 file linked from some online page.
However, You can look at this Streaming Audio tutorial as an initial reference. The MediaPlayer API would be your goto place in android for anything to do with Audio/ Video. WebView is mainly for embedding a browser view within your android App.
Here is an example quite close to the thing you're going to do...
public class MyJSInterface{
private MediaPlayer mp = new MediaPlayer();
....
public void play(String url){
this.mp.setDataSource(url);
this.mp.prepare();
this.mp.start();
// AlterDialog etc.
}
public void stop(){
this.mp.stop();
}
....
}
HTML from your website:
function _play(url){
window.myappname.play(url);
}
function _stop(url){
window.myappname.stop();
}
thing you may need
Android Media