3

I have an app that is using a webview to launch an html that loads JWP7 and throws an error Uncaught TypeError :cannot read property 'jwplayer.volume' of null The same page is loading perfectly on mobile and desktop browsers. I tried to add in the javascript of the html after the jwplayer.js is being called and before the setup, the following code:

if (typeof jwplayer.volume == "undefined" || typeof jwplayer.volume == null )
    jwplayer.volume = 10;

I do see the new volume property using a desktop/mobile browser but it doesn't changes the TypeError in the webview, probably because the TypeError is thrown while running the jwplayer.js script, before it reaches my javascript check.

When i'm Using the JWP6 everything is working perfectly.

Any suggestions on how to fix it?

ohadsas
  • 479
  • 2
  • 7
  • 23

2 Answers2

19

I inspected the jwplayer.js code. And saw that it reads the last settings of Volume (jwplayer.volume) and Mute (jwplayer.mute) from the LocalStorage; instead of from cookie. (Probably JWPlayer 6 was using cookies.)

So, you need to enable LocalStorage access in your WebView; like you do for JavaScript.

Sample code below.

WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true); // This will allow access
webView.setWebViewClient(new WebViewClient());
/* WebView.setWebContentsDebuggingEnabled(true);  // This is to inspect your WebView from desktop Chrome. (>= API 19) You may not want to include this in production. */
webView.loadUrl(url);
ashazar
  • 714
  • 5
  • 11
1

JW Player doesn't support using the web player in Android or iOS webview; however, there are native mobile SDKs available to support in-app video: developer.jwplayer.com/android-sdk

Josie Keller
  • 477
  • 2
  • 8