-
Notifications
You must be signed in to change notification settings - Fork 12
VPlayer API
-
VPlayerView
- Static Constants
- Constructor
- Setters
- View LifeCycle
- Video Controls
- Getters
- VPlayerListener
The VPlayerView is a View object that you can attach to layouts. It has extra commands to control video such as pause, play and seek.
Allow the player to pick the first available stream (video, audio and/or subtitle).
Allow the player to not select a video, audio or subtitle stream from video.
- Param activity: the activity where you are placing this view
Makes the current activity fullscreen; removes the actionbar etc.
Restores the activity's actionbar and goes out of fullscreen
####void setDataSource(String path, String fontPath, String encryptKey, int videoIndex, int audioIndex, int subtitleIndex)
- Param path: path to the file or url to a video stream
- Param fontPath: path to a font file (*.ttf); null not use subtitles
- Param encryptKey: encryption key if the video has encryption, otherwise can set as null
- Param videoIndex: the video index of the stream to use
- Param audioIndex: the audio index of the stream to use
- Param subtitleIndex: the subtitle index of the stream to use
Streams can specify numbers or static members UNKNOWN_STREAM / NO_STREAM.
Note: you can get the metadata of a video and set the stream after from MediaStreamInfo using the VPlayerListener -> onMediaSourceLoaded
Simple method to just run a video with subtitles with encryption key. It will take the first available stream.
Simple method to just run a video specifying the video and audio indexes.
Simple method to just run a video with subtitles. It will take the first available stream.
Simple method to just run a video with no encryption or subtitles. It will take the first available stream.
- Param shouldLoop: set if the video should play again when finished
- Param listener: set the event listener to receive video state events
Activity should call this function on its onPause() method.
Activity should call this function on its onResume() method.
Activity should call this function on its finish() method. You can also use this in other places if not finish(), then it will close the video player and you cannot use it again.
These controls are usable as long as setDataSource is successful and before finish() is called, otherwise these methods are ignored.
Pause the video
- Param position: specify the position of playback in seconds
Play the current video
Stops the player and resets the position back to the beginning of the video
- Return: gets the video width once video is loaded (wait for onMediaSourceLoaded event)
- Return: gets the video height once video is loaded (wait for onMediaSourceLoaded event)
- Return: sees if the video is currently playing
This is an abstract class used to get events from VPlayerView.
- Param err: an error when pausing
This event happens when pausing is successful
- Param result: an error when resuming
This event happens when resuming is successful
- Param result: an error when seeking
This event happens when seeking is successful
- Param err: an error when opening network stream or file and playback will not happen
- Param streams: returns all the streams (video, audio and subtitle) contained in current video
Stop has occured
- Param currentTime: current time of the playback
- Param totalDuration: total number of seconds playing the video
- Param isFinished: true when video is finished playback
This event occurs every second. You can detect when the video has finished and update a seekbar if you implement one.