"Media app: Android platform Vitamio player Discovery Road Series" bis: Vitamio API: Core class

Source: Internet
Author: User

Guo Jia
Email: [Email protected]
Blog: http://blog.csdn.net/allenwells
Github:https://github.com/allenwells

"Media Apps: Android platform Vitamio player Discovery Trail Series" Chapter Index

"Media app: Android platform Vitamio player Discovery Road Series" bis: Vitamio API

Note : In order to facilitate people to view the source code, Vitamio API Introduction According to the Vitamio source code package name to classify categories. As shown in the following:

A MediaPlayer1.1 overview

MediaPlayer can control playback of music/video and network streams. You can find ways to use this class from Videoview.
This class works much the same as Android.media.MediaPlayer. See the Developer Guide for audio and video using MediaPlayer.

1.2 Constant 1.2.1 public static final int Media_error_unknown

Playback error, unknown error.
Constant Value: 0

1.2.2 public static final int Media_error_not_valid_for_progressive_playback

Playback error (General video playback is slow or the video itself has a problem will be raised).
Constant Value: 200

1.2.3 public static final int media_info_video_track_lagging

The video is too complex to decode: the frame cannot be decoded quickly. You may only play audio correctly at this time. See Mediaplayer.oninfolistener.
Constant Value: 700

1.2.4 public static final int Media_info_buffering_start

MediaPlayer pause playback waits for more data to be buffered.
Constant Value: 701

1.2.5 public static final int media_info_buffering_end

MediaPlayer continues to play after Buffering is complete.
Constant Value: 702

1.2.6 public static final int media_info_not_seekable

Seek, such as live stream, is not supported by the media.
Constant value: 801

1.2.7 public static final int media_info_download_rate_changed

The speed of the Av_read_frame () (KB/S).
Constant Value: 901

1.2.8 public static final int Videoquality_low

Video quality-Smooth.
Constant value: 16

1.2.9 public static final int Videoquality_medium

Video quality-Normal.
Constant Value: 0

1.2.10 public static final int Videoquality_high

Video quality
Constant value: 16

1.2.11 public static final int subtitle_internal

Subtitles are displayed from built-in captions.
Constant Value: 0

1.2.12 public static final int subtitle_external

Subtitles are displayed from external subtitles.
Constant Value: 1

1.2.13 public static final string[] Sub_types

Vitamio support for external subtitle types.
Constant value: {". srt", ". SSA", ". Smi", ". txt", ". Sub", "."}

1.3 Method 1.3.1 public static Final Boolean islibraryloaded ()

Whether the dynamic link library (so) has successfully loaded completed.

1.3.2 public void Setdisplay (Surfaceholder sh)

Sets the surfaceholder for displaying media video. This call is optional. This method is not called when only the audio is displayed and the video is not displayed (for example, background playback).
Parameters
Surfaceholder of the sh user display video

1.3.3 public void Setdatasource (context context, URI Uri)

Set up a multimedia data source, such as a context Uri. (Support raw resource access, for example: android.resource://com.your.package/r.raw.your_resource_id)

Parameters
context to use when getting contentresolver
URI you want to play the URI

Exception
Thrown when the IllegalArgumentException state is invalid (thrown when the URI or context is empty)

1.3.4 public native void Setdatasource (String path)

Sets the data source (file path or Http/rtsp/mms URL).

1.3.5 public native void Setdatasource (FileDescriptor fd)

Sets the data source (filedescriptor). The most secure way for callers to shut down their filedescriptor after a call is to close them as soon as they return.

1.3.6 Public native void prepare ()

Pre-processing the player prepares for playback by executing synchronously.
After you've set up your data source and displayed surface, you'll need to call prepare () or Prepareasync (). For files, you can call prepare until the media player is ready to play.

1.3.7 public native void Prepareasync ()

The preprocessing player prepares for playback by executing asynchronously.
After you've set up your data source and displayed surface, you'll need to call prepare () or Prepareasync (). For the stream, you should call Prepareasync () and return immediately instead of blocking until enough data is buffered.

1.3.8 public void Start ()

Start or resume playback. If the playback has been paused before, it will be played from where it was paused. If it has stopped playing or has not started playing, playback will start from the beginning.

1.3.9 public void Stop ()

Same as pause ().

1.3.10 public void Pause ()

Pauses playback. Call Start () to resume.

1.3.11 public void Setwakemode (context context, int mode)

Set the underlying power management for the MediaPlayer. You can use the high-level setscreenonwhileplaying feature when MediaPlayer is not set Setdisplay playback through Surfaceholder.
This method is used when the MediaPlayer accesses a low-level power management control device power supply. The parameter is a Android.os.PowerManager wake-up combination identity. Using this method requires Wake_lock permissions. It is not used by default to keep the device awake for playback.

Parameters

Context
Mode setting Powermanger Power/Lock mode

1.3.12 public void Setscreenonwhileplaying (Boolean Screenon)

Controls whether to use an additional surfaceholder to keep the screen highlighted and continue playing the video. This method may be preferable to using setwakemode because it does not require the application to access the underlying wake-up lock.

Parameters

Screenon set True to keep the screen highlighted, and vice versa to allow it to close.

1.3.13 Public native int Getvideowidth ()

Gets the video width.

return value

Returns the width of the video, no video or width is not determined when 0 is returned. You can get a notification by registering Onvideosizechangedlistener when the width is valid.

1.3.13 Public native int Getvideoheight ()

Gets the video height.

return value

Returns the height of the video, no video or height is not determined when 0 is returned. You can get a notification by registering Onvideosizechangedlistener when it is highly effective.

1.3.14 Public Native Boolean isplaying ()

Detects if the MediaPlayer is playing.
public native void Seekto (long msec)
Sets the playback to the specified time position.

Parameters
msec offset from start position to msec (in milliseconds)

Abnormal

IllegalStateException internal playback engine not initialized raised

1.3.15 Public native long GetCurrentPosition ()

Gets the current playback position.

1.3.16 Public native Bitmap Getcurrentframe ()

Gets the current video frame. (Available for)

1.3.17 Public native long Getduration ()

Gets the multimedia playback duration.

1.3.18 public void Release ()

Releases resources related to MediaPlayer. It is a good programming habit to call this method when you are finished using MediaPlayer.

1.3.19 public void Reset ()

Resets (reset) MediaPlayer to uninitialized state. After calling this method, you need to set the data source again and initialize it with prepare ().

1.3.20 public native void SetVolume (float leftvolume, float rightvolume))

Set the volume. (Range 0.0~1.0)

1.3.21 public void Setonpreparedlistener (Onpreparedlistener listener))

Registers a callback function that is called after the video preprocessing is complete.

1.3.22 public void Setoncompletionlistener (Oncompletionlistener l)

Registers a callback function that is called after the video playback is complete.

1.3.23 public void Setonerrorlistener (Onerrorlistener l)

Registers a callback function that is called when an error occurs during an asynchronous operation call. For example, video open failed.

1.3.24 public void Setonbufferingupdatelistener (Onbufferingupdatelistener l)

Registers a callback function that is called when the network video stream buffers changes.

1.3.25 public void Setonseekcompletelistener (Onseekcompletelistener l)

Registers a callback function that is called after the seek operation is complete.

1.3.26 public void Setonvideosizechangedlistener (Onvideosizechangedlistener listener)

Registers a callback function that is called after the video size is known or updated.

1.3.27 public void Setonsubtitleupdatelistener (Onsubtitleupdatelistener l)

Registers a callback function that is called when the caption needs to be displayed.

1.3.28 public void Setoninfolistener (Oninfolistener l)

Registers a callback function that is called when there is a warning or error message. For example: Start buffering, buffer end, download speed change.

1.3.29 public void Releasedisplay ()

This effect is called when the audio is played.

1.3.30 Public native float Getvideoaspectratio ()

Gets the video width-to-height ratio.

return value

Returns the width-to-height ratio of the video. No video or wide-height incorrectly returns 0. See Videoview.setvideolayout.

1.3.31 public native void setvideoquality (int quality)

Set the video quality. If the playback delay is serious, you can try using Videoquality_low (smooth), default videoquality_low (smooth).

Parameters

Quality See constants for MediaPlayer: Videoquality_low (Fluent), Videoquality_medium (normal), Videoquality_high (high quality).

1.3.32 public native void Setdeinterlace (Boolean deinterlace)

Sets video anti-interlacing.

1.3.33 public native void setbuffersize (int bufSize)

Sets the video buffer size (default 1024KB) unit byte.

1.3.34 Public Native Boolean isbuffering ()

Detects if the buffer is complete.

1.3.35 Public native int getbufferprogress ()

See Onbufferingupdatelistener.

1.3.36 public native void setmetaencoding (String encoding)

Sets the metadata encoding. Example: UTF-8

1.3.37 Public native String getmetaencoding ()

Gets the metadata encoding.

1.3.38 public HashMap Getaudiotrackmap (String encoding)

Gets the audio tracks embedded in the video. For example: 中文版

1.3.39 Public native int Getaudiotrack ()

Sets the playback track number.

1.3.40 public native void setaudiotrack (int audioindex)

To set the track number, you must use the return value of Getaudiotrackmap.

1.3.41 public void Setinitialaudiotrack (int audioindex)

Sets the audio track to initialize.

1.3.42 public void Setinitialsubtrack (int subindex)

Sets the initial caption.

1.3.43 public native void Setsubshown (Boolean shown)

Sets whether captions are displayed.

Parameters

shown true indicates that subtitles are displayed

1.3.44 public native void setsubencoding (String encoding)

Sets the caption encoding.

Parameters

encoding subtitle encoding. If NULL is automatically detected.

1.3.45 Public native int getsublocation ()

Gets the caption position type. 0 for inline subtitles, 1 for external subtitles.

1.3.46 public native void Setsubpath (String subpath)

Sets the external caption path. Must be a local file path.

1.3.47 Public native String Getsubpath ()

Gets the external caption path.

1.3.48 public native void setsubtrack (int trackid)

Sets the caption number. Must be a return value of Getsubtrackmap.

1.3.49 Public native int Getsubtrack ()

Gets the caption number.

1.3.50 public HashMap Getsubtrackmap (String encoding)

Gets the video inline caption collection.

Parameters

encoding format string encoding. If NULL is automatically detected.

return value

Returns a map that consists of a caption name and a caption number.

1.4 Protected method 1.4.1 protected void Finalize ()

Called the native_finalize.

1.5 MediaPlayer Internal Interface 1.5.1 public interface Onbufferingupdatelistener

void Onbufferingupdate (MediaPlayer MP, int percent)

Updates the streaming media cache status.

Parameters

    • MP to update the MediaPlayer
    • percent percent buffered (0 ~ 100)
1.5.2 Public Interface Onerrorlistener

Boolean OnError (MediaPlayer MP, int what, int extra)
Error message.

Parameters

    • MP errors related to MediaPlayer
    • What type of error, see Media_error_unknown, Media_error_not_valid_for_progressive_playback
    • extra Extra specific error code. Usually depends on the implementation.

return value

Returns true if the error was handled, otherwise false is returned. Returns false or no setting Onerrorlistener will be thrown Oncompletionlistener is called.

1.5.3 public Interface Oninfolistener

Boolean Oninfo (MediaPlayer MP, int what, int extra)
Information or warnings.

Parameters

    • MP information related to MediaPlayer
    • What information or warning type, see media_info_video_track_lagging,

Media_info_buffering_start, Media_info_buffering_end, media_info_not_seekable, media_info_download_rate_changed
Extra additional specific information code. Usually depends on the implementation.

return value

Returns true if the error was handled, otherwise false is returned. Returns false or does not set Oninfolistener to discard information or warnings.

1.5.4 public Interface Onsubtitleupdatelistener

public void Onsubtitleupdate (String text)

Text captions need to be displayed.

public void onsubtitleupdate (byte[] pixels, int width, int height)

Picture captions need to be displayed.

Parameters

    • pixels Picture subtitle pixel
    • width Picture subtitle widths
    • height picture subtitle Heights

"Media app: Android platform Vitamio player Discovery Road Series" bis: Vitamio API: Core class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.