Difference between revisions of "Android Player Intents"
Jump to navigation
Jump to search
(Add position description) |
|||
(13 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
=Open a media with VLC Player= | =Open a media with VLC Player= | ||
− | |||
To play a media with VLC player, use an intent with the following settings | To play a media with VLC player, use an intent with the following settings | ||
== action == | == action == | ||
− | Intent.ACTION_VIEW ("android.intent.action.VIEW") | + | Intent.ACTION_VIEW ("android.intent.action.VIEW") |
− | |||
== Package name == | == Package name == | ||
− | "org.videolan.vlc" | + | "org.videolan.vlc" |
− | |||
− | == | + | == data == |
The media Uri | The media Uri | ||
− | + | == type == | |
− | == | ||
one of: | one of: | ||
Line 44: | Line 40: | ||
* misc/ultravox | * misc/ultravox | ||
+ | == Extras (optional) == | ||
− | = | + | {| class="wikitable" |
− | + | |- | |
− | + | ! Value !! Type !! Description | |
− | + | |- | |
+ | | "subtitles_location" || String || Path of a subtitles file | ||
+ | |- | ||
+ | | "title" || String || Title you want to display | ||
+ | |- | ||
+ | | "from_start" || boolean || Force playback from the beginning | ||
+ | |- | ||
+ | | "position" || int/long || Set position to start playback, in milliseconds | ||
+ | |- | ||
+ | | "extra_duration" || long || Media duration | ||
+ | |} | ||
== Sample code == | == Sample code == | ||
+ | For a simple media playback: | ||
int vlcRequestCode = 42; | int vlcRequestCode = 42; | ||
Uri uri = Uri.parse("file:///storage/emulated/0/Movies/KUNG FURY Official Movie.mp4"); | Uri uri = Uri.parse("file:///storage/emulated/0/Movies/KUNG FURY Official Movie.mp4"); | ||
Intent vlcIntent = new Intent(Intent.ACTION_VIEW); | Intent vlcIntent = new Intent(Intent.ACTION_VIEW); | ||
vlcIntent.setPackage("org.videolan.vlc"); | vlcIntent.setPackage("org.videolan.vlc"); | ||
− | vlcIntent. | + | vlcIntent.setDataAndTypeAndNormalize(uri, "video/*"); |
− | vlcIntent.putExtra("position", | + | vlcIntent.putExtra("title", "Kung Fury"); |
− | vlcIntent.putExtra("subtitles_location", "/ | + | vlcIntent.putExtra("from_start", false); |
+ | vlcIntent.putExtra("position", 90000l); | ||
+ | vlcIntent.putExtra("subtitles_location", "/sdcard/Movies/Fifty-Fifty.srt"); | ||
startActivityForResult(vlcIntent, vlcRequestCode); | startActivityForResult(vlcIntent, vlcRequestCode); | ||
+ | |||
+ | If you specifically want start VideoPlayerActivity, you can set | ||
+ | vlcIntent.setComponent(new ComponentName("org.videolan.vlc", "org.videolan.vlc.gui.video.VideoPlayerActivity")); | ||
=Get result code from VLC= | =Get result code from VLC= | ||
Line 66: | Line 79: | ||
==Intent action== | ==Intent action== | ||
− | "org.videolan.vlc.player.result" | + | "org.videolan.vlc.player.result" |
− | |||
==Result code== | ==Result code== | ||
Line 86: | Line 98: | ||
| RESULT_VIDEO_TRACK_LOST || 5 || VLC continues playback, but for audio track only. (Audio file detected or user chose to) | | RESULT_VIDEO_TRACK_LOST || 5 || VLC continues playback, but for audio track only. (Audio file detected or user chose to) | ||
|} | |} | ||
− | |||
==Data== | ==Data== | ||
Media Uri | Media Uri | ||
+ | You can check the source [http://git.videolan.org/?p=vlc-ports/android.git;a=blob;f=vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java;hb=HEAD here]. | ||
==Extras== | ==Extras== | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Value !! Type !! Description | ||
+ | |- | ||
+ | | "extra_position" || long || Last position in media when player exited | ||
+ | |- | ||
+ | | "extra_duration" || long || Total duration of the media | ||
− | + | |} | |
− | |||
+ | ==See also== | ||
+ | * [[Android Report bugs]] - Bug reporting guide for VLC-Android. | ||
− | + | [[Category:Building]] [[Category:Android]] |
Latest revision as of 10:24, 29 June 2016
Contents
Open a media with VLC Player
To play a media with VLC player, use an intent with the following settings
action
Intent.ACTION_VIEW ("android.intent.action.VIEW")
Package name
"org.videolan.vlc"
data
The media Uri
type
one of:
- video/*
- audio/*
- */rmvb
- */avi
- */mkv
- application/3gpp*
- application/mp4
- application/mpeg*
- application/ogg
- application/sdp
- application/vnd.3gp*
- application/vnd.apple.mpegurl
- application/vnd.dvd*
- application/vnd.dolby*
- application/vnd.rn-realmedia*
- application/x-iso9660-image
- application/x-extension-mp4
- application/x-flac
- application/x-matroska
- application/x-mpegURL
- application/x-ogg
- application/x-quicktimeplayer
- application/x-shockwave-flash
- application/xspf+xml
- misc/ultravox
Extras (optional)
Value | Type | Description |
---|---|---|
"subtitles_location" | String | Path of a subtitles file |
"title" | String | Title you want to display |
"from_start" | boolean | Force playback from the beginning |
"position" | int/long | Set position to start playback, in milliseconds |
"extra_duration" | long | Media duration |
Sample code
For a simple media playback:
int vlcRequestCode = 42; Uri uri = Uri.parse("file:///storage/emulated/0/Movies/KUNG FURY Official Movie.mp4"); Intent vlcIntent = new Intent(Intent.ACTION_VIEW); vlcIntent.setPackage("org.videolan.vlc"); vlcIntent.setDataAndTypeAndNormalize(uri, "video/*"); vlcIntent.putExtra("title", "Kung Fury"); vlcIntent.putExtra("from_start", false); vlcIntent.putExtra("position", 90000l); vlcIntent.putExtra("subtitles_location", "/sdcard/Movies/Fifty-Fifty.srt"); startActivityForResult(vlcIntent, vlcRequestCode);
If you specifically want start VideoPlayerActivity, you can set
vlcIntent.setComponent(new ComponentName("org.videolan.vlc", "org.videolan.vlc.gui.video.VideoPlayerActivity"));
Get result code from VLC
Since version 1.4.1, Android VLC application returns an intent when closing.
Here is the description of this intent:
Intent action
"org.videolan.vlc.player.result"
Result code
Result | Value (int) | Description |
---|---|---|
RESULT_OK | -1 | Video finished or user ended playback |
RESULT_CANCELED | 0 | No compatible cpu, incorrect VLC abi variant installed |
RESULT_CONNECTION_FAILED | 2 | Connection failed to audio service |
RESULT_PLAYBACK_ERROR | 3 | VLC is not able to play this file, it could be incorrect path/uri, not supported codec or broken file |
RESULT_HARDWARE_ACCELERATION_ERROR | 4 | Error with hardware acceleration, user refused to switch to software decoding |
RESULT_VIDEO_TRACK_LOST | 5 | VLC continues playback, but for audio track only. (Audio file detected or user chose to) |
Data
Media Uri
You can check the source here.
Extras
Value | Type | Description |
---|---|---|
"extra_position" | long | Last position in media when player exited |
"extra_duration" | long | Total duration of the media |
See also
- Android Report bugs - Bug reporting guide for VLC-Android.