OHOS::Media::Player

Overview

Related Modules:

MultiMedia_Player

Description:

Provides functions for playing online movies, offline movies, and streams, for example, playing local movies and advanced audio coding (AAC) streams.

Since:

1.0

Version:

1.0

Summary

Public Member Functions

Public Member Function Name

Description

SetSource (const Source &source)

int32_t 

Sets the playback source for the player. The corresponding source can be the file descriptor (FD) of the local file, local file URI, network URI, or media stream.

Prepare ()

int32_t 

Prepares the playback environment and buffers media data.

Play ()

int32_t 

Starts or resumes playback.

IsPlaying ()

bool 

Checks whether the player is playing.

Pause ()

int32_t 

Pauses playback.

Stop ()

int32_t 

Stops playback.

Rewind (int64_t mSeconds, int32_t mode)

int32_t 

Changes the playback position.

SetVolume (float leftVolume, float rightVolume)

int32_t 

Sets the volume of the player.

SetVideoSurface (Surface *surface)

int32_t 

Sets a surface for video playback.

EnableSingleLooping (bool loop)

int32_t 

Sets loop playback.

IsSingleLooping ()

bool 

Checks whether the player is looping.

GetCurrentTime (int64_t &time) const

int32_t 

Obtains the playback position, accurate to millisecond.

GetDuration (int64_t &duration) const

int32_t 

Obtains the total duration of media files, in milliseconds.

GetVideoWidth (int32_t &videoWidth)

int32_t 

Obtains the width of the video.

GetVideoHeight (int32_t &videoHeight)

int32_t 

Obtains the height of the video.

Reset ()

int32_t 

Restores the player to the initial state.

Release ()

int32_t 

Releases player resources.

SetPlayerCallback (const std::shared_ptr< PlayerCallback > &cb)

void 

Registers a listener to receive events and exception notifications from the player.