Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

JWPlayer and fullscreen in Android Webview?


Hi, I'm trying out JWPlayer in webviews in android and while it works almost perfectly (poster loads, video plays, tracking works), for some reason fullscreen mode isn't working. The fullscreen button in the JWP controls doesn't do anything (and it feels as it it takes a couple of touches before it actually gets "pressed") - and I get nothing to console and nothing in LogCat. It just.. doesn't work, and I can't really find any info on why. I have tried this on both android 4.4x and 4.3, with the same result. 4.3 uses Chrome 24 internally, and 4.4 uses Chrome 30 (iirc). I've also tried this with both a cloudhosted and selfhosted JWP 6.8.4616.

Here's the simple HTML:

bc.. <html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>HTML5 Player Framework - Declarative Usage Example</title>
<script type="text/javascript" src="http://<url redacted>/jwplayer.js"></script>
<script type="text/javascript">jwplayer.key="<key redacted>";</script>
</head>
<body>
<h1>HTML5 Player Framework</h1>
<h2>Declarative Usage Example</h2>
<div id="myElement">Loading the player ...</div>
<script type="text/javascript">
jwplayer("myElement").setup({
file: "https://<url redacted>",
height: 360,
image: "https://<url redacted>",
width: 640
});
jwplayer().setFullscreen(true);
</script>
</body>
</html>



And the relevant android code:
bc.. MainActivity.java:
package com.semcon.android.jwvideotest;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {

@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
mWebView.getSettings().setLoadsImagesAutomatically(true);
mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.loadUrl("file:///android_asset/index.html");
}
}



Any clues?

5 Community Answers

JW Player

User  
0 rated :

Oh, and forgot to mention: The exact same HTML file works (fullscreen) if I load it in the standalone Chrome (33.x) in Android.

JW Player

User  
0 rated :

I feel your pain, on touch event is a little clonkey.

I use
bc.. <a href="#" onClick='jwplayer().setFullscreen("true")' data-role="button">Full Screen</a>



For full screen.

But some times i get errors on certain phones, full screen:

bc.. java.lang.NullPointerException
at android.webkit.HTML5VideoView.isPlaying(HTML5VideoView.java:122)
at android.webkit.HTML5VideoViewProxy$VideoPlayer.isPlaying(HTML5VideoViewProxy.java:253)
at android.webkit.HTML5VideoViewProxy.handleMessage(HTML5VideoViewProxy.java:402)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)

JW Player

User  
0 rated :

Thanks for the tip, didn't get it to work however, and no error output either :)

JW Player

User  
0 rated :

Using "*setFullscreen(true)*" does work yet it sporadically cause issues with video.

A <u>possible</u> alternative or workaround is to use the viewport or screenport dimensions to resize the JWPlayer.

bc.. using jquery

var x = $(window).innerWidth();
var y = $(window).innerHeight();
jwplayer().resize(x,y)



Not sur eif this is helpful for you but worth a try

Ethan Feldman

JW Player Support Agent  
0 rated :

We have not tested the player in a webview, I’m afraid.

This question has received the maximum number of answers.