# MultiMedia\_Player ## **Overview** Defines the **Player** class and provides functions related to media playback. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Files
Declares the Player class, which is used to implement player-related operations. |
OHOS::Media::PlayerSeekMode : int32_t { OHOS::Media::PLAYER_SEEK_PREVIOUS_SYNC = 0, OHOS::Media::PLAYER_SEEK_NEXT_SYNC, OHOS::Media::PLAYER_SEEK_CLOSEST_SYNC, OHOS::Media::PLAYER_SEEK_CLOSEST, OHOS::Media::PLAYER_SEEK_FRAME_INDEX } |
Enumerates player seek modes. You can move the current playback position of the media to a given time position using the specified mode. |
OHOS::Media::PlayerStates : uint32_t { OHOS::Media::PLAYER_STATE_ERROR = 0, OHOS::Media::PLAYER_IDLE = 1 << 0, OHOS::Media::PLAYER_INITIALIZED = 1 << 1, OHOS::Media::PLAYER_PREPARING = 1 << 2, OHOS::Media::PLAYER_PREPARED = 1 << 3, OHOS::Media::PLAYER_STARTED = 1 << 4, OHOS::Media::PLAYER_PAUSED = 1 << 5, OHOS::Media::PLAYER_STOPPED = 1 << 6, OHOS::Media::PLAYER_PLAYBACK_COMPLETE = 1 << 7 } |
|
OHOS::Media::PlayerCallback::PlayerInfoType : int32_t { OHOS::Media::PlayerCallback::PLAYER_INFO_RENDER_START = 0 } |
OHOS::Media::PlayerCallback::OnError (int32_t errorType, int32_t errorCode)=0 |
|
OHOS::Media::PlayerCallback::OnInfo (int type, int extra)=0 |
|
OHOS::Media::PlayerCallback::OnVideoSizeChanged (int width, int height)=0 |
|
OHOS::Media::Player::SetSource (const Source &source) |
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. |
OHOS::Media::Player::Rewind (int64_t mSeconds, int32_t mode) |
|
OHOS::Media::Player::SetVolume (float leftVolume, float rightVolume) |
|
OHOS::Media::Player::SetVideoSurface (Surface *surface) |
|
OHOS::Media::Player::EnableSingleLooping (bool loop) |
|
OHOS::Media::Player::GetCurrentTime (int64_t &time) const |
|
OHOS::Media::Player::GetDuration (int64_t &duration) const |
|
OHOS::Media::Player::GetVideoWidth (int32_t &videoWidth) |
|
OHOS::Media::Player::GetVideoHeight (int32_t &videoHeight) |
|
OHOS::Media::Player::SetPlayerCallback (const std::shared_ptr< PlayerCallback > &cb) |
Registers a listener to receive events and exception notifications from the player. |
PLAYER_INFO_RENDER_START |
PLAYER_STATE_ERROR | |
PLAYER_IDLE | |
PLAYER_INITIALIZED | |
PLAYER_PREPARING | |
PLAYER_PREPARED | |
PLAYER_STARTED | |
PLAYER_PAUSED | |
PLAYER_STOPPED | |
PLAYER_PLAYBACK_COMPLETE |
loop | Specifies whether to enable loop playback. The value true means to enable loop playback, and false means to disable loop playback. |
time | Indicates the playback position. |
duration | Indicates the total duration of media files. |
videoHeight | Indicates the video height. |
videoWidth | Indicates the video width. |
errorType | Indicates the error type. For details, see PlayerErrorType. |
errorCode | Indicates the error code. |
type | Indicates the information type. For details, see PlayerInfoType. |
extra | Indicates the information code. |
width | Indicates the video width. |
height | Indicates the video height. |
mSeconds | Indicates the target playback position, accurate to second. |
mode | Indicates the player seek mode. For details, see PlayerSeekMode. |
cb | Indicates the listener to register. For details, see PlayerCallback. |
source | Indicates the playback source. Currently, only local file URIs and media streams are supported. For details, see Source. |
surface | Indicates the surface to set. For details, see Surface. |
leftVolume | Indicates the target volume of the left audio channel to set, ranging from 0 to 300. |
rightVolume | Indicates the target volume of the right audio channel to set, ranging from 0 to 300. |