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

How To include JW Player in Android App


Hi Longtailvideo Support Team,

I currently do some experiments on how to build an Android App with video playback capabilities. My test platform is a HTC One X with Android 4.x ICS.

I use the PhoneGap/Cordova project in combination with jQuery Mobile to build the app. My primary objective is that the video playback should not only work on Android 4.x ICS with native HTML5 video support but also on older versions with a Flash video plugin so I got the idea to simply try the JW player with this scenario.

Apart from some minor video playback issues, this idea works good when I test it beforehand in the Mobile Safari on my HTC X Android device where the JW player.swf is loaded from a webserver. However, when I put the player.swf and jwplayer.js to the local resource storage of the app, compile and start the app, the player.swf doesn't load.

My code looks similar to

jwplayer("video").setup({
flashplayer: "jwplayer/player.swf",
provider: "rtmp",
streamer: "rtmp://www.blafoo.com/",
file: "video.mp4",
events: {
onReady: notifyReady,
onError: notifyError
}
});

Although my debugging possibilities are limited within the App, it seems that the jwplayer.js embedder can be found and works normally as expected. However, neither the onReady event nor the onError event is raised, the video area on the screen simply stays blank.

I assume that it might be related to the way on how local resources are handled within android apps. If I understand it correctly, all files are handled as local file system requests, so my player file e.g. will be loaded from

file:///android_asset/www/jwplayer/player.swf

Do you already have some experiences related to this scenario? Is it possible that the file:// prefix in android apps raises a problem? Actually, I do not want to load the player.swf from a remote server everytime a user starts watching a video on his mobile device when I can also be stored directly within the app (the App should have enouth security privileges to access and load these local file resources)

Thanks in advance

Andre

5 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

I have heard of PhoneGap before, but I have never personally used it. Theoretically this should work, but I think you are going to need the player files on a web server in order for this to work properly.

JW Player

User  
0 rated :

Thanks Ethan for your immediate reply. I will try your advice.

Andre

Ethan Feldman

JW Player Support Agent  
0 rated :

Np

JW Player

User  
0 rated :

If anybody of you is interested in my results, here is a brief summary of my experiences...

JW Player 5.x works together with PhoneGap/Cordova, that means you can use it to build a "native" android app.

There are two issues you have to pay attention to:

- if you want to use the player in Flash mode in Android version 11+, you have to explicitly enable Flash plugin support by using

WebSettings settings = super.appView.getSettings();
settings.setPluginState(PluginState.ON);

and in Android version 14+, you have to enable android:hardwareAccelerated="true" for your application in the AndroidManifest.xml

- if the JW player is stored locally in the assets/www directory, it raises a "could not connect to application error 2028" if you want to playback e.g. a remote VoD via RTMP. If you load the player via http from a web server URL, everything works fine as Ethan already stated.

Andre

Ethan Feldman

JW Player Support Agent  
0 rated :

Thank you for sharing :)

This question has received the maximum number of answers.