# MultiMedia\_Player - [Overview](#section1987368586165625) - [Summary](#section525725604165625) - [Files](#files) - [Data Structures](#nested-classes) - [Enumerations](#enum-members) - [Functions](#func-members) - [Details](#section1769927466165625) - [Enumeration Type](#section40029736165625) - [PlayerInfoType](#ga7dac9dac65cbbea7e411adcf2c314ac5) - [PlayerSeekMode](#gad1574e5769b3174c2103a2a8b49e20d4) - [PlayerStates](#ga8b1147e57c4a67f63f193836302da2b7) - [Function](#section747638434165625) - [EnableSingleLooping\(\)](#gae19989aa6e80b768acd4eb019a2b60d2) - [GetCurrentTime\(\)](#ga8474b117a4c1bf5749406f26056b4802) - [GetDuration\(\)](#ga24ae07f65da4dafc4ec5aa28321625d8) - [GetVideoHeight\(\)](#ga726adc32a34134b30aabfbdb389c8357) - [GetVideoWidth\(\)](#ga9ed94bd43d896fa10066497377d7fbda) - [IsPlaying\(\)](#gaad6b2c35b1d5dfe453d158f7ff9e1379) - [IsSingleLooping\(\)](#gae4dd5d8fb92c836f5304f181a40b34d2) - [OnError\(\)](#ga3d0fdad57045f5e049b56de031d3e0fb) - [OnInfo\(\)](#gad2d3466c8a17ee4d622b87fa6a31b2bb) - [OnPlaybackComplete\(\)](#ga3b56f618340bf9a5590e6142b2311302) - [OnRewindToComplete\(\)](#ga765c499e47dfaad5e557197e964eaca3) - [OnVideoSizeChanged\(\)](#gac5b641f93621d90e616d18adaa016e8a) - [Pause\(\)](#gae1d2225ce60a9737cc902e586138a44f) - [Play\(\)](#gafecbbfe85c70cf4983f52d55b7205e3f) - [Prepare\(\)](#gade9bff3268e1c409273749a90700e056) - [Release\(\)](#ga00e24c0faed483c9d54e416ec2ffe6ac) - [Reset\(\)](#ga75e17ee0068d46d44a30709609821b85) - [Rewind\(\)](#ga406b6277d1e160e691d01f5f740480b3) - [SetPlayerCallback\(\)](#gabb6eca611514d5fc0b66df5ff2d70c2b) - [SetSource\(\)](#gacce284eac910970e405151fd3a1963c0) - [SetVideoSurface\(\)](#gac9d62210915ebcf3b462574302018501) - [SetVolume\(\)](#ga23ca57f0b1a288980e37153274c5f8b3) - [Stop\(\)](#gafe518a5b909ac0f0f066781caa3b55aa) ## **Overview** **Description:** 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. |