nchutchind / cordova-plugin-app-launcher

Simple Cordova plugin for launching apps.
MIT License
88 stars 94 forks source link

launcher add support for return info from app #2

Closed michael1t closed 9 years ago

michael1t commented 10 years ago

Hello,

I would like to be able to pass extras to the app and get the returned info from the app. Things like video Position , play lists , ect...

Return info would include position , video duration , play complete .. ect ..

See below info for the player ...

I am using android and phonegap build site

The app I would like to start with is the MX player ... I have attached the extras request parameters ...

Thanks Michael T.

API - Intent definition Intent definition to launch playback activity of MX Player. Also check sample codes attached below.

Unlike its page name, this is not actually an API definition but just an Intent definition for playing back videos through MX Player.

Using this Intent definition,

You CAN;

Play single or multiple videos.
Provide subtitles to be drawn together.
Select decoder and simple options such as video zoom, etc.
Receive playback result including whether it is completed or not, last playback position, etc.

You CANNOT;

Play or pause playback.
Touch user interface.
Change playback options except provided ones.
Change settings.
Access native features of MX Player such as extracting thumbnails, search videos, etc.

[Supported Version]

Since 1.6

[Package]

com.mxtech.videoplayer.pro - Pro Edition

com.mxtech.videoplayer.ad - Free Edition.

[Action: android.intent.action.VIEW]

Data: 

    Uri pointing to a media source.

Extras: 

    (All extras are optional)

    decode_mode

    Type: byte

    Values: 1 - h/w decoder 2 - s/w decoder

    fast_mode

    Type: boolean

    Values: true to use s/w fast mode when s/w decoder is seelcted.

    Fast mode is deprecated. Even though this can improve decoding speed in some cases, there are also chances degrade video output quality. It is not recommended at all.

    video_list

    Type: parcelable array (android.net.Uri[])

    Values: video play list including uri provided on Data.

    To prevent loading next file automatically, provide single sized array having only "Data".

    The uri used as the Intent data should be included in the video_list either.
    For example, to play 1.mp4, 2.mp4, 3.mp4 in sequence, set data to 1.mp4 and put { 1.mp4, 2.mp4, 3.mp4 } to video_list.

    If uri points to a file, it should be canonicalized. See File.getCanonicalPath.

    video_list.name  Added in 1.7.31
    Type: String[]
    Values: Custom video titles for each videos in video_list to be displayed to users.

    Array should have same size as video_list. Array elements can point to null instead of valid string. In this case, default name will be used.

    If video_list.name and title is provided together, video_list.name will be used and title will be ignored.

    subs

    Type: parcelable array (android.net.Uri[])

    Values: subtitle list used for given video uri (in data field)

    subs.name  Added in 1.7.31

Type: String[]
Values: Custom subtitle names to be displayed to users.

Array should have same size as subs. Array elements can point to null instead of valid string. In this case, default name will be used.

Even if this extra is provided, custom name will not be used for subtitles defining name inside script or containing multiple tracks in a script file such as SAMI subtitles.

    subs.enable  Added in 1.6e
    Type: parcelable array (android.net.Uri[])
    Values: Initially visible subtitles.

    In the following cases, subtitle URI is different from file URI since single file can contain multiple subtitle tracks.

        SAMI Subtitles: {file-uri}#{track-name} ex) file:///sdcard/movie1.smi#encc

    title

    Type: String

    Values: video title text.

    position

    Type: int

    Values: resume position in milliseconds. presence of this extra forces to resume given position not giving user a chance to play from the beginning.

    return_result

    Type: boolean

    Values: set true to receive resulting intent through Activity.onActivityResult() call.

    headers  Added in 1.7.11
    Type: String[]
    Values: the headers to be sent together with the request for the uri.

    Key and value should appear in turn. e.g) String[] headers = { "User-Agent", "Mozilla compatible/1.0", "Extra-Header", "Extra-header-value" };

    This feature has limitation if used for HW decoder; 1) It only works with Android 2.2 and above. 2) Before Android 4.0, default header cannot be overriden. For example, if you pass "User-Agent", it will not replace default User-Agent to given value but default and given header will be passed altogether.

    suppress_error_message  Added in 1.7.14
    Type: boolean
    Value: If set to true and error occurs, activity will play next video or close itself not showing error message.

    secure_uri   Added in 1.7.14
    Type: boolean
    Value: If set to true, video uri will not be displayed in the property dialog box.

    video_zoom   Added in 1.7.23
    Type: int
    Value: Override video zoom setting. Available values are: Fit to screen=1, Stretch=0, Crop=3, 100%=2

    DAR_horz, DAR_vert  Added in 1.7.23
    Type: float
    Value: Override default DAR(display aspect ratio). Both extras should be provided together.

    sticky  Added in 1.7.23
    Type: boolean
    Value: Override background play setting.

[Result: com.mxtech.intent.result.VIEW]

Code:

    Activity.RESULT_OK : when playback was completed or stoped by user request.

Data:

    last played video uri. 

Extras:
decode_mode
Type: byte
Value: Used decoding mode

position
Type: int
Value: Last playback position in milliseconds. This extra will not exist if playback is completed.

duration  Added in 1.7.23
Type: int
Value: Duration of last played video in milliseconds. This extra will not exist if playback is completed.

end_by  Added in 1.7.19
Type: String
Value: Indicates reason of activity closure. Can be one of following values:

    "user": User requested to leave activity.
    "playback_completion": All playback completed.

[MIME Type]

By setting proper MIME type, you can avoid ActivityNotFoundException exception regardless of passing URI.

Even if MIME type is not provided, Intent can be delivered to MX Player depending on the file extension of Intent uri(data). Most popular extensions are supported including avi, mkv, mp4, 3gp, asf, divx, flv, ts, wmv and so forth.

*CAVEAT: For http/https URIs, result will not be returned unless directly specifying activity class name by calling Intent.setClassName(). Class name for free edition is com.mxtech.videoplayer.ad.ActivityScreen and pro edition is com.mxtech.videoplayer.ActivityScreen.     

For example,

    Intent intent = new Intent(Intent.ACTION_VIEW);

    Uri videoUri = Uri.parse("http://host:port/playlist.m3u8");

    intent.setDataAndType( videoUri, "application/x-mpegURL" );

    intent.setPackage( "com.mxtech.videoplayer.pro" );

    startActivity( intent );

Supported MIME types:

    video/*

    */rmvb

    */avi

    */mkv

    application/sdp

    application/mp4

    application/mpeg*

    application/ogg
    application/x-ogg

    application/vnd.rn-realmedia*

    application/3gpp*

    application/vnd.3gp*

    application/vnd.dvd*

    application/vnd.dolby*

    application/x-mpegURL

    application/vnd.apple.mpegurl

    application/x-quicktimeplayer
    application/x-shockwave-flash
nchutchind commented 10 years ago

This is not a difficult enhancement, but I am currently unable to devote time. If anyone can implement it and send me a pull request, I'd appreciate it.

nchutchind commented 9 years ago

This has been implemented.