You can use an intent to directly launch the player of mpv-android.
package: is.xyz.mpv
action: android.intent.action.VIEW
rtmp, rtmps, rtp, rtsp, mms, mmst, mmsh, tcp, udp
(as supported by FFmpeg)content, file, http, https
video/*
or audio/*
http, https
and file extension mkv, mp4, webm, mov, flac, mp3, ogg, m3u, m3u8
If you need to force an URL to be opened in mpv regardless of the file
extension set the MIME type to video/any
.
extras: (all optional)
decode_mode
(Byte): if set to 2, hardware decoding will be disabled
subs
(ParcelableArray of Uri): list of subtitle URIs to be added as additional tracks
subs.enable
(ParcelableArray of Uri): specifies which of the subtitles should be selected by default, subset of previous array
position
(Int): starting point of video playback in milliseconds
title
(String): media title to show for this file
val intent = Intent(Intent.ACTION_VIEW) intent.setDataAndType(Uri.parse("https://example.org/media.png"), "video/any") intent.setPackage("is.xyz.mpv") val subtitle = Uri.parse("https://example.org/subtitle.srt") intent.putExtra("subs", arrayOf<Uri>(subtitle)) startActivity(intent)
<a href="intent://example.org/media.png#Intent;type=video/any;package=is.xyz.mpv;scheme=https;end;">Click me</a>
am start -a android.intent.action.VIEW -t video/any -p is.xyz.mpv -d "https://example.org/media.png"
Once the activity exits mpv-android will deliver a result intent back to the invoker.
action: is.xyz.mpv.MPVActivity.result
code:
RESULT_CANCELED
: playback did not start due to an errorRESULT_OK
: playback ended normally or user exiteddata: the same URI mpv was launched with
extras:
position
(Int): last playback position in milliseconds. not present if playback finished normallyduration
(Int): total media length in milliseconds. not present if playback finished normallyThis API was inspired by the counterpart in MXPlayer.
Note that only Java code is powerful enough to use the full features of this specification or receive result intents.