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

Android SDK - Play file stored on sdcard


Hi,

Is it possible to play local files with the JWPlayer Android SDK ?

I tried to define file("file://path_to_local_file") but it gave me an error...

Thanks,

Regards

5 Community Answers

George

JW Player Support Agent  
1 rated :

Hi,

It is possible to play local files, it really depends on how you get the actual file path. You could use the MediaStore and use a pick intent to get the video from your gallery then you’d have to get the actual file path from the URI.
http://stackoverflow.com/questions/17546101/get-real-path-for-uri-android

Or you could download/place the file in a known local directory and do something like this:
String docPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
String fileName = contentUri.toString().substring(contentUri.toString().indexOf(“%2F”) + 3);
String path = “file://” + docPath “/” fileName;

Or you could use the assets folder in Android Studio and have a path such as:
file:///android_asset/five_no_fullscreen.css

s...

User  
1 rated :

Hi,

thanks for the fast answer. Please, See below what I'm doing.

The file location looks good cause I can open it with the standard MediaPlayer.

The filepath I pass to the PlayerConfig builder :

String path = "file:///storage/emulated/0/Android/data/com.xxxx.lib/files/COURS/2288/xxxxxxx.mp4"

PlayerConfig playerConfig = new PlayerConfig.Builder()
.file(path)
.autostart(true)
.build();


And the error on the VideoView :

com.google.android.exoplay.upstream.HttpDataSource$HttpDataSourceException : unable to connec to
http://intercept.jw/file:///storage/emulated/0/Android/data/com.xxxx.lib/files/COURS/2288/xxxxxxxx.mp4

As if the player was trying to open a remote http URL while it's a local file...

Did I miss something ?

Thanks

George

JW Player Support Agent  
2 rated :

No, that is a known bug in the current version. Try setting the file to a PlaylistItem object then load that into the player

s...

User  
1 rated :

That works,

Thanks a lot for the fast support !

Regards.

George

JW Player Support Agent  
1 rated :

Anytime

This question has received the maximum number of answers.