VMediaPlayer Class Reference
Inherits from | VSingleton |
Declared in | VMediaPlayer.h |
Tasks
Shared Instance
VMediaPlayer Setup&unSetup Methods
VMediaPlayer Manger Preference Methods
-
autoSwitchDecodingScheme
property -
decodingSchemeHint
property -
decodingSchemeUsing
property -
useCache
property
Player Control
-
– setDataSource:
-
– setDataSource:header:
-
– setDataSegmentsSource:fileList:
-
– setCacheDirectory:
-
– setOptionsWithKeys:withValues:
-
– prepareAsync
-
– start
-
– pause
-
– isPlaying
-
– reset
-
– getDuration
-
– getCurrentPosition
-
– seekTo:
-
– setPlaybackSpeed:
-
– setAdaptiveStream:
-
– isUsingHardwareDecoding
-
– setMetaEncoding:
-
– getMetaEncoding
-
– getMetadata
-
– getDiskSize
Video Control
-
– setVideoShown:
-
– getVideoTracksArray
-
– setVideoTrackWithArrayIndex:
-
– getVideoTrackCurrentArrayIndex
-
– setVideoQuality:
-
– getVideoWidth
-
– getVideoHeight
-
– getVideoAspectRatio
-
– setDeinterlace:
-
– getCurrentFrame
Audio Control
-
– getAudioTracksArray
-
– setAudioTrackWithArrayIndex:
-
– getAudioTrackCurrentArrayIndex
-
– setVolume:
-
– getVolume
-
– setChannelVolumeLeft:right:
-
– getChannelVolumeLeft:right:
-
– setAudioAmplify:
Subtitle Control
-
– setSubShown:
-
– getSubTracksArray
-
– setSubTrackWithArrayIndex:
-
– getSubTrackCurrentArrayIndex
-
– addSubTrackToArrayWithPath:
-
– setSubTrackWithPath:
-
– getCurSubText
-
– setSubEncoding:
Buffering
Caches
Player View Control
Properties
autoSwitchDecodingScheme
Specifies whether auto switch decoding scheme when media player prepared failed
with the hint of decodingSchemeHint
, default is YES.
@property (atomic, assign, readwrite) BOOL autoSwitchDecodingScheme
See Also
Declared In
VMediaPlayer.h
decodingSchemeHint
Specifies the hint of decoding scheme, default is VMDecodingSchemeSoftware
.
@property (atomic, assign, readwrite) emVMDecodingScheme decodingSchemeHint
See Also
Declared In
VMediaPlayer.h
decodingSchemeUsing
The decoding scheme of media player using at this time.
@property (atomic, assign, readonly) emVMDecodingScheme decodingSchemeUsing
See Also
Declared In
VMediaPlayer.h
Instance Methods
setupPlayerWithCarrierView:withDelegate:
Setup the media player to work with the given view and the given VMediaPlayerDelegate
implementor.
- (BOOL)setupPlayerWithCarrierView:(UIView *)carrier withDelegate:(id<VMediaPlayerDelegate>)dlg
Parameters
- carrier
The view of video picture will rendering to.
- delegate
The protocol to setup.
Return Value
Returns YES or NO if setup fails.
See Also
Declared In
VMediaPlayer.h
unSetupPlayer
Unsetup the media player.
- (BOOL)unSetupPlayer
Return Value
Returns YES or NO if the media player have not ever setup yet.
Declared In
VMediaPlayer.h
setDataSource:
Set the media url to media player.
- (void)setDataSource:(NSURL *)mediaURL
Parameters
- mediaURL
The url of media want to play.
See Also
Declared In
VMediaPlayer.h
setDataSource:header:
Set the media url to media player, and also pass protocol header to it.
- (void)setDataSource:(NSURL *)mediaURL header:(NSString *)header
Parameters
- mediaURL
The url of media want to play.
- header
The protocol header, e.g. HTTP header.
Discussion
This method is provide for some online media stream, the parameter header is usefull for media player on open and prepare the media stream, but it is not necessary. optionally, You can use setOptionsWithKeys:withValues: method to do that.
Declared In
VMediaPlayer.h
setDataSegmentsSource:fileList:
Set the media segment urls to media player.
- (void)setDataSegmentsSource:(NSString *)baseURL fileList:(NSArray *)list
Parameters
- baseURL
The base url to locate steam file list. Can be nil.
- list
The segments list.
Discussion
This method is provide for some media stream, which contain by many segments.
See Also
Declared In
VMediaPlayer.h
setCacheDirectory:
Set the diretory for cache data to store.
- (void)setCacheDirectory:(NSString *)directory
Discussion
@param directory
Declared In
VMediaPlayer.h
setOptionsWithKeys:withValues:
Pass options to media.
- (void)setOptionsWithKeys:(NSArray *)keys withValues:(NSArray *)values
Discussion
@param keys @param values
See Also
Declared In
VMediaPlayer.h
prepareAsync
Prepares the player for playback, asynchronously.
- (void)prepareAsync
Discussion
After setting the datasource , you need to call prepareAsync, which returns immediately.
It will trigger the protocol mediaPlayer:didPrepared:
when player prepared successfully
or mediaPlayer:erro:
if failed.
See Also
Declared In
VMediaPlayer.h
start
Starts or resumes playback.
- (void)start
Discussion
If playback had previously been paused, playback will continue from where it was paused. If playback had been stopped, or never started before, playback will start at the beginning.
Declared In
VMediaPlayer.h
isPlaying
Checks whether the VMediaPlayer is playing.
- (BOOL)isPlaying
Return Value
YES if currently playing, NO otherwise.
Declared In
VMediaPlayer.h
reset
Resets the VMediaPlayer to its uninitialized state.
- (void)reset
Discussion
After calling this
method, you will have to initialize it again by setting the data source setDataSource:
and
calling prepareAsync
.
Declared In
VMediaPlayer.h
getDuration
Gets the duration of the media.
- (long)getDuration
Return Value
Returns the duration in milliseconds, or -1 if error occur.
Declared In
VMediaPlayer.h
getCurrentPosition
Gets the current playback position.
- (long)getCurrentPosition
Return Value
Returns the current position in milliseconds, or -1 if orror occur.
Declared In
VMediaPlayer.h
seekTo:
Seeks to specified time position.
- (void)seekTo:(long)msec
Parameters
- msec
the offset in milliseconds from the start to seek to.
Declared In
VMediaPlayer.h
setPlaybackSpeed:
Set video and audio playback speed.
- (void)setPlaybackSpeed:(float)speed
Parameters
- speed
e.g. 0.8 or 2.0, default to 1.0, range in [0.5-2]
Declared In
VMediaPlayer.h
setAdaptiveStream:
Adaptive streaming support, default is NO.
- (BOOL)setAdaptiveStream:(BOOL)adaptive
Parameters
- adaptive
YES if wanna adaptive steam.
Declared In
VMediaPlayer.h
isUsingHardwareDecoding
Checks whether the VMediaPlayer is using hardware decoding.
- (BOOL)isUsingHardwareDecoding
Return Value
Returns YES if it is using hardware decoding, NO otherwise.
Declared In
VMediaPlayer.h
setMetaEncoding:
Set the encoding VMediaPlayer will use to determine the metadata.
- (void)setMetaEncoding:(NSString *)encoding
Parameters
- encoding
e.g. “UTF-8”
Declared In
VMediaPlayer.h
getMetaEncoding
Get the encoding if haven’t set with setMetaEncoding:
- (NSString *)getMetaEncoding
Return Value
Returns the encoding of meta data, or nil if error occurs.
Declared In
VMediaPlayer.h
getMetadata
Gets the media metadata.
- (NSDictionary *)getMetadata
Return Value
Returns the metadata, possibly empty, or nil if errors occurred.
Declared In
VMediaPlayer.h
getDiskSize
Gets the size on disk of the media.
- (long long)getDiskSize
Return Value
Return the size in bytes, or -1 if error occurs.
Declared In
VMediaPlayer.h
setVideoShown:
Tell the VMediaPlayer whether to show video.
- (void)setVideoShown:(BOOL)shown
Parameters
- shown
YES if wanna show
Declared In
VMediaPlayer.h
getVideoTracksArray
- Returns an array of video tracks information. *
- The usage see in
getAudioTracksArray
.
- (NSArray *)getVideoTracksArray
Discussion
- @return Returns Array of video track info. The total number of tracks is the array length;
if error occurs, nil is returned.
Declared In
VMediaPlayer.h
setVideoTrackWithArrayIndex:
Switch to a new video track.
- (BOOL)setVideoTrackWithArrayIndex:(int)index
Parameters
- index
One of the indexes of array return by
getVideoTracksArray
.
Return Value
Returns YES for success or NO if error occur.
Discussion
Tell VMediaPlayer switch the video track to the new track indicate by index.
See Also
Declared In
VMediaPlayer.h
getVideoTrackCurrentArrayIndex
Get the video track index of player play currently.
- (int)getVideoTrackCurrentArrayIndex
Return Value
Returns the video track index play currently, or -1 if error occurs.
See Also
Declared In
VMediaPlayer.h
setVideoQuality:
Set the quality when play video.
- (void)setVideoQuality:(emVMVideoQuality)quality
Parameters
- quality
The quality(
emVMVideoQuality
) want to set.
Discussion
If the video is too lag, you may try VIDEOQUALITY_LOW, default is VIDEOQUALITY_LOW.
Declared In
VMediaPlayer.h
getVideoWidth
Returns the width of the video.
- (int)getVideoWidth
Return Value
The width of the video, or 0 if there is no video, or the width has not been determined yet.
Declared In
VMediaPlayer.h
getVideoHeight
Returns the height of the video.
- (int)getVideoHeight
Return Value
The height of the video, or 0 if there is no video, or the height has not been determined yet.
Declared In
VMediaPlayer.h
getVideoAspectRatio
Returns the aspect ratio of the video.
- (float)getVideoAspectRatio
Return Value
The aspect ratio of the video, or 0 if there is no video, or the width and height is not available.
Declared In
VMediaPlayer.h
setDeinterlace:
Set if should deinterlace the video picture.
- (void)setDeinterlace:(BOOL)deinterlace
Parameters
- deinterlace
Pass YES if need deinterlace, NO if not.
Declared In
VMediaPlayer.h
getCurrentFrame
Get the current video frame.
- (UIImage *)getCurrentFrame
Return Value
Return the UIImage object, or nil if error occurs.
Declared In
VMediaPlayer.h
getAudioTracksArray
Returns an array of audio tracks information.
- (NSArray *)getAudioTracksArray
Return Value
Returns array of audio track info. The total number of tracks is the array length; returns nil if the current decoding scheme is not support get audio track info.
Discussion
The return array is contained by NSDictionary. Every track infomation map to a dictionary.
You can use the key of VMMediaTrackLocationType
or VMMediaTrackId
etc. to get the
detail. Here’s an example of simple usage:
NSArray *tracks = [player getAudioTracksArray];
for (NSDictionary *track in tracks) {
NSLog(@"LocationType: %d, id: %d, title: %@, exPath: %@",
[track[VMMediaTrackLocationType] intValue],
track[VMMediaTrackId] ? [track[VMMediaTrackId] intValue] : -1,
track[VMMediaTrackTitle] ? track[VMMediaTrackTitle] : @"(none)",
track[VMMediaTrackFilePath] ? track[VMMediaTrackFilePath] : @"(none)"
);
}
Declared In
VMediaPlayer.h
setAudioTrackWithArrayIndex:
Switch to a new audio track.
- (BOOL)setAudioTrackWithArrayIndex:(int)index
Parameters
- index
One of the indexes of array return by
getAudioTracksArray
.
Return Value
Returns YES for success or NO if error occur.
Discussion
Tell VMediaPlayer switch the audio track to the new track indicate by index.
See Also
Declared In
VMediaPlayer.h
getAudioTrackCurrentArrayIndex
Get the audio track index of player play currently.
- (int)getAudioTrackCurrentArrayIndex
Return Value
Returns the audio track index play currently, or -1 if error occurs.
See Also
Declared In
VMediaPlayer.h
setVolume:
Set the media player output volume.
- (void)setVolume:(float)volume
Parameters
- volume
The volume value, range in [0.0-1.0].
Declared In
VMediaPlayer.h
getVolume
Get the media player output volume value.
- (float)getVolume
Return Value
Returns the current media player volume.
Declared In
VMediaPlayer.h
setChannelVolumeLeft:right:
Set the left/right volume balance for a stereo audio.
- (void)setChannelVolumeLeft:(float)left right:(float)right
Parameters
- left
The left balance, range in [0.0-1.0].
- right
The right balance, range in [0.0-1.0].
Declared In
VMediaPlayer.h
getChannelVolumeLeft:right:
Get the left/right volume balance for a stereo audio.
- (void)getChannelVolumeLeft:(float *)left right:(float *)right
Parameters
- left
The left balance return store in *left.
- right
The right balance return store in *left.
Declared In
VMediaPlayer.h
setAudioAmplify:
Amplify audio
- (BOOL)setAudioAmplify:(float)ratio
Parameters
- ratio
e.g. 3.5
Declared In
VMediaPlayer.h
setSubShown:
Tell the VMediaPlayer whether to show timed text.
- (void)setSubShown:(BOOL)shown
Parameters
- shown
YES if wanna show
Declared In
VMediaPlayer.h
getSubTracksArray
Returns an array of subtitle tracks information.
- (NSArray *)getSubTracksArray
Return Value
Return array of subtitle track info, The total number of tracks is the array length; if error occurs, nil is returned.
Discussion
The usage see in getAudioTracksArray
.
Declared In
VMediaPlayer.h
setSubTrackWithArrayIndex:
Switch to a new subtitle track.
- (BOOL)setSubTrackWithArrayIndex:(int)index
Parameters
- index
One of the indexes of array return by
getSubTracksArray
.
Return Value
Returns YES for success or NO if error occur.
Discussion
Tell VMediaPlayer switch the subtitle track to the new track indicate by index.
See Also
Declared In
VMediaPlayer.h
getSubTrackCurrentArrayIndex
Get the subtitle track index of player play currently.
- (int)getSubTrackCurrentArrayIndex
Return Value
Returns the subtitle track index play currently, -1 if error occurs.
See Also
Declared In
VMediaPlayer.h
addSubTrackToArrayWithPath:
Add a new subtitle track in exteranl subtitle file to the subtitle array.
It will contain in the array return by follow called getSubTracksArray
.
- (BOOL)addSubTrackToArrayWithPath:(NSString *)path
Parameters
- path
The path of external subtitle to add.
Return Value
Returns YES or NO if error occurs.
See Also
Declared In
VMediaPlayer.h
setSubTrackWithPath:
Switch to a new subtitle track by external subtitle.
- (void)setSubTrackWithPath:(NSString *)path
Parameters
- path
The path of external subtitle to use.
Declared In
VMediaPlayer.h
getCurSubText
Get the timed text at current time.
- (NSString *)getCurSubText
Return Value
Returns timed text.
Declared In
VMediaPlayer.h
setSubEncoding:
Set the encoding to display timed text.
- (void)setSubEncoding:(NSString *)encoding
Parameters
- encoding
VMediaPlayer will detet it if nil.
Declared In
VMediaPlayer.h
setBufferSize:
The buffer to fill before playback, default is 1024KB
- (void)setBufferSize:(int)bufSize
Parameters
- bufSize
buffer size in Byte
Declared In
VMediaPlayer.h
isBuffering
Checks whether the buffer is filled
- (BOOL)isBuffering
Return Value
NO if buffer is filled
Declared In
VMediaPlayer.h
getBufferProgress
Get buffer progress.
- (int)getBufferProgress
Return Value
the percent
Declared In
VMediaPlayer.h
setVideoFillMode:
Tell media playback view which video fill mode to use.
- (void)setVideoFillMode:(emVMVideoFillMode)fillMode
Parameters
- fillMode
The mode in
emVMVideoFillMode
Declared In
VMediaPlayer.h
getVideoFillMode
Get video fill mode of playback view using.
- (emVMVideoFillMode)getVideoFillMode
Return Value
The mode using now.
Declared In
VMediaPlayer.h
setVideoFillScale:
Set the playback view scale, default 1.0
- (void)setVideoFillScale:(float)scale
Parameters
- scale
e.g. 0.5
Declared In
VMediaPlayer.h
getVideoFillScale
Get the current playback view scale.
- (float)getVideoFillScale
Return Value
The playback scale.
Declared In
VMediaPlayer.h
setVideoFillAspectRatio:
Set the playback view aspect ratio.
- (void)setVideoFillAspectRatio:(float)ratio
Parameters
- ratio
aspect ratio
Discussion
The aspect ratio of video is auto detect by VMediaPlayer, but it may be failed, so you need use this method to set the right aspect ratio for media player.
Declared In
VMediaPlayer.h