18c77b71bSopenharmony_ci/*
28c77b71bSopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
38c77b71bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
48c77b71bSopenharmony_ci * you may not use this file except in compliance with the License.
58c77b71bSopenharmony_ci * You may obtain a copy of the License at
68c77b71bSopenharmony_ci *
78c77b71bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
88c77b71bSopenharmony_ci *
98c77b71bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
108c77b71bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
118c77b71bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128c77b71bSopenharmony_ci * See the License for the specific language governing permissions and
138c77b71bSopenharmony_ci * limitations under the License.
148c77b71bSopenharmony_ci */
158c77b71bSopenharmony_ci
168c77b71bSopenharmony_ci/**
178c77b71bSopenharmony_ci * @addtogroup MultiMedia_Player
188c77b71bSopenharmony_ci * @{
198c77b71bSopenharmony_ci *
208c77b71bSopenharmony_ci * @brief Defines the <b>Player</b> class and provides functions related to media playback.
218c77b71bSopenharmony_ci *
228c77b71bSopenharmony_ci *
238c77b71bSopenharmony_ci * @since 1.0
248c77b71bSopenharmony_ci * @version 1.0
258c77b71bSopenharmony_ci */
268c77b71bSopenharmony_ci
278c77b71bSopenharmony_ci/**
288c77b71bSopenharmony_ci * @file player.h
298c77b71bSopenharmony_ci *
308c77b71bSopenharmony_ci * @brief Declares the <b>Player</b> class, which is used to implement player-related operations.
318c77b71bSopenharmony_ci *
328c77b71bSopenharmony_ci *
338c77b71bSopenharmony_ci * @since 1.0
348c77b71bSopenharmony_ci * @version 1.0
358c77b71bSopenharmony_ci */
368c77b71bSopenharmony_ci
378c77b71bSopenharmony_ci#ifndef PLAYER_H
388c77b71bSopenharmony_ci#define PLAYER_H
398c77b71bSopenharmony_ci
408c77b71bSopenharmony_ci#include "source.h"
418c77b71bSopenharmony_ci#include "format.h"
428c77b71bSopenharmony_ci#include <memory>
438c77b71bSopenharmony_ci#include <vector>
448c77b71bSopenharmony_ci#ifndef SURFACE_DISABLED
458c77b71bSopenharmony_ci#include "surface.h"
468c77b71bSopenharmony_ci#endif
478c77b71bSopenharmony_ci
488c77b71bSopenharmony_cinamespace OHOS {
498c77b71bSopenharmony_cinamespace Media {
508c77b71bSopenharmony_ci/**
518c77b71bSopenharmony_ci * @brief Enumerates player seek modes. You can move the current playback position of the media to a given time
528c77b71bSopenharmony_ci * position using the specified mode.
538c77b71bSopenharmony_ci *
548c77b71bSopenharmony_ci * @since 1.0
558c77b71bSopenharmony_ci * @version 1.0
568c77b71bSopenharmony_ci */
578c77b71bSopenharmony_cienum PlayerSeekMode : int32_t {
588c77b71bSopenharmony_ci    /** Moves the media position to the latest synchronization frame located before the given time position. */
598c77b71bSopenharmony_ci    PLAYER_SEEK_PREVIOUS_SYNC = 0,
608c77b71bSopenharmony_ci    /** Moves the media position to the latest synchronization frame located after the given time position. */
618c77b71bSopenharmony_ci    PLAYER_SEEK_NEXT_SYNC,
628c77b71bSopenharmony_ci    /** Moves the media position to the latest synchronization frame located before or after the given time position. */
638c77b71bSopenharmony_ci    PLAYER_SEEK_CLOSEST_SYNC,
648c77b71bSopenharmony_ci    /** Moves the media position to the latest frame located before or after the given time position. */
658c77b71bSopenharmony_ci    PLAYER_SEEK_CLOSEST,
668c77b71bSopenharmony_ci};
678c77b71bSopenharmony_ci
688c77b71bSopenharmony_ci/**
698c77b71bSopenharmony_ci * @brief Enumerates player states.
708c77b71bSopenharmony_ci *
718c77b71bSopenharmony_ci * @since 1.0
728c77b71bSopenharmony_ci * @version 1.0
738c77b71bSopenharmony_ci */
748c77b71bSopenharmony_cienum PlayerStates : uint32_t {
758c77b71bSopenharmony_ci    /** Error */
768c77b71bSopenharmony_ci    PLAYER_STATE_ERROR = 0,
778c77b71bSopenharmony_ci    /** Idle */
788c77b71bSopenharmony_ci    PLAYER_IDLE = 1 << 0,
798c77b71bSopenharmony_ci    /** Initialized */
808c77b71bSopenharmony_ci    PLAYER_INITIALIZED = 1 << 1,
818c77b71bSopenharmony_ci    /** Preparing */
828c77b71bSopenharmony_ci    PLAYER_PREPARING = 1 << 2,
838c77b71bSopenharmony_ci    /** Prepared */
848c77b71bSopenharmony_ci    PLAYER_PREPARED = 1 << 3,
858c77b71bSopenharmony_ci    /** Playback started */
868c77b71bSopenharmony_ci    PLAYER_STARTED = 1 << 4,
878c77b71bSopenharmony_ci    /** Playback paused */
888c77b71bSopenharmony_ci    PLAYER_PAUSED = 1 << 5,
898c77b71bSopenharmony_ci    /** Playback stopped */
908c77b71bSopenharmony_ci    PLAYER_STOPPED = 1 << 6,
918c77b71bSopenharmony_ci    /** Playback completed */
928c77b71bSopenharmony_ci    PLAYER_PLAYBACK_COMPLETE = 1 << 7
938c77b71bSopenharmony_ci};
948c77b71bSopenharmony_ci
958c77b71bSopenharmony_ci/**
968c77b71bSopenharmony_ci * @brief Provides listeners for events and exception notifications that occur during media playback.
978c77b71bSopenharmony_ci *
988c77b71bSopenharmony_ci * @since 1.0
998c77b71bSopenharmony_ci * @version 1.0
1008c77b71bSopenharmony_ci */
1018c77b71bSopenharmony_ciclass PlayerCallback {
1028c77b71bSopenharmony_cipublic:
1038c77b71bSopenharmony_ci    enum PlayerInfoType : int32_t {
1048c77b71bSopenharmony_ci        /** Pushed the first video frame for rendering */
1058c77b71bSopenharmony_ci        PLAYER_INFO_RENDER_START = 0,
1068c77b71bSopenharmony_ci    };
1078c77b71bSopenharmony_ci
1088c77b71bSopenharmony_ci    enum PlayerErrorType : int32_t {
1098c77b71bSopenharmony_ci        PLAYER_ERROR_UNKNOWN = 0,
1108c77b71bSopenharmony_ci    };
1118c77b71bSopenharmony_ci
1128c77b71bSopenharmony_ci    PlayerCallback() = default;
1138c77b71bSopenharmony_ci    virtual ~PlayerCallback() = default;
1148c77b71bSopenharmony_ci
1158c77b71bSopenharmony_ci    /**
1168c77b71bSopenharmony_ci    * @brief Called when the playback is complete.
1178c77b71bSopenharmony_ci    *
1188c77b71bSopenharmony_ci    * @since 1.0
1198c77b71bSopenharmony_ci    * @version 1.0
1208c77b71bSopenharmony_ci    */
1218c77b71bSopenharmony_ci    virtual void OnPlaybackComplete() = 0;
1228c77b71bSopenharmony_ci
1238c77b71bSopenharmony_ci    /**
1248c77b71bSopenharmony_ci    * @brief Called when a playback error occurs.
1258c77b71bSopenharmony_ci    *
1268c77b71bSopenharmony_ci    * @param errorType Indicates the error type. For details, see {@link PlayerErrorType}.
1278c77b71bSopenharmony_ci    * @param errorCode Indicates the error code.
1288c77b71bSopenharmony_ci    * @since 1.0
1298c77b71bSopenharmony_ci    * @version 1.0
1308c77b71bSopenharmony_ci    */
1318c77b71bSopenharmony_ci    virtual void OnError(int32_t errorType, int32_t errorCode) = 0;
1328c77b71bSopenharmony_ci
1338c77b71bSopenharmony_ci    /**
1348c77b71bSopenharmony_ci    * @brief Called when playback information is received.
1358c77b71bSopenharmony_ci    *
1368c77b71bSopenharmony_ci    * @param type Indicates the information type. For details, see {@link PlayerInfoType}.
1378c77b71bSopenharmony_ci    * @param extra Indicates the information code.
1388c77b71bSopenharmony_ci    * @since 1.0
1398c77b71bSopenharmony_ci    * @version 1.0
1408c77b71bSopenharmony_ci    */
1418c77b71bSopenharmony_ci    virtual void OnInfo(int type, int extra) = 0;
1428c77b71bSopenharmony_ci
1438c77b71bSopenharmony_ci    /**
1448c77b71bSopenharmony_ci    * @brief Called when the video image size changes.
1458c77b71bSopenharmony_ci    *
1468c77b71bSopenharmony_ci    * @param width Indicates the video width.
1478c77b71bSopenharmony_ci    * @param height Indicates the video height.
1488c77b71bSopenharmony_ci    * @since 1.0
1498c77b71bSopenharmony_ci    * @version 1.0
1508c77b71bSopenharmony_ci    */
1518c77b71bSopenharmony_ci    virtual void OnVideoSizeChanged(int width, int height) = 0;
1528c77b71bSopenharmony_ci
1538c77b71bSopenharmony_ci    /**
1548c77b71bSopenharmony_ci    * @brief Called when the rewind is complete.
1558c77b71bSopenharmony_ci    *
1568c77b71bSopenharmony_ci    * @since 1.0
1578c77b71bSopenharmony_ci    * @version 1.0
1588c77b71bSopenharmony_ci    */
1598c77b71bSopenharmony_ci    virtual void OnRewindToComplete() = 0;
1608c77b71bSopenharmony_ci};
1618c77b71bSopenharmony_ci
1628c77b71bSopenharmony_ci/**
1638c77b71bSopenharmony_ci * @brief Provides functions for playing online movies, offline movies, and streams, for example, playing local
1648c77b71bSopenharmony_ci * movies and advanced audio coding (AAC) streams.
1658c77b71bSopenharmony_ci *
1668c77b71bSopenharmony_ci * @since 1.0
1678c77b71bSopenharmony_ci * @version 1.0
1688c77b71bSopenharmony_ci */
1698c77b71bSopenharmony_ciclass Player {
1708c77b71bSopenharmony_cipublic:
1718c77b71bSopenharmony_ci    Player();
1728c77b71bSopenharmony_ci    ~Player();
1738c77b71bSopenharmony_ci
1748c77b71bSopenharmony_ci    /**
1758c77b71bSopenharmony_ci     * @brief Sets the playback source for the player. The corresponding source can be the file descriptor (FD) of the
1768c77b71bSopenharmony_ci     * local file, local file URI, network URI, or media stream.
1778c77b71bSopenharmony_ci     *
1788c77b71bSopenharmony_ci     * @param source Indicates the playback source. Currently, only local file URIs and media streams are supported.
1798c77b71bSopenharmony_ci     * For details, see {@link Source}.
1808c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns <b>-1</b> otherwise.
1818c77b71bSopenharmony_ci     * @since 1.0
1828c77b71bSopenharmony_ci     * @version 1.0
1838c77b71bSopenharmony_ci     */
1848c77b71bSopenharmony_ci    int32_t SetSource(const Source &source);
1858c77b71bSopenharmony_ci
1868c77b71bSopenharmony_ci    /**
1878c77b71bSopenharmony_ci     * @brief Prepares the playback environment and buffers media data.
1888c77b71bSopenharmony_ci     *
1898c77b71bSopenharmony_ci     * This function must be called after {@link SetSource}.
1908c77b71bSopenharmony_ci     *
1918c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the playback environment is prepared and media data is buffered;
1928c77b71bSopenharmony_ci     * returns <b>-1</b> otherwise.
1938c77b71bSopenharmony_ci     * @since 1.0
1948c77b71bSopenharmony_ci     * @version 1.0
1958c77b71bSopenharmony_ci     */
1968c77b71bSopenharmony_ci    int32_t Prepare();
1978c77b71bSopenharmony_ci
1988c77b71bSopenharmony_ci    /**
1998c77b71bSopenharmony_ci     * @brief Starts or resumes playback.
2008c77b71bSopenharmony_ci     *
2018c77b71bSopenharmony_ci     * This function must be called after {@link Prepare}. If the player state is <b>Prepared</b>, this function is
2028c77b71bSopenharmony_ci     * called to start playback. If the player state is <b>Playback paused</b>, this function is called to resume
2038c77b71bSopenharmony_ci     * playback. If the media is playing in an abnormal speed, this function is called to restore the playback speed
2048c77b71bSopenharmony_ci     * to normal.
2058c77b71bSopenharmony_ci     *
2068c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the playback starts or resumes; returns <b>-1</b> otherwise.
2078c77b71bSopenharmony_ci     * @since 1.0
2088c77b71bSopenharmony_ci     * @version 1.0
2098c77b71bSopenharmony_ci     */
2108c77b71bSopenharmony_ci    int32_t Play();
2118c77b71bSopenharmony_ci
2128c77b71bSopenharmony_ci    /**
2138c77b71bSopenharmony_ci     * @brief Checks whether the player is playing.
2148c77b71bSopenharmony_ci     *
2158c77b71bSopenharmony_ci     * @return Returns <b>true</b> if the player is playing; returns <b>false</b> otherwise.
2168c77b71bSopenharmony_ci     * @since 1.0
2178c77b71bSopenharmony_ci     * @version 1.0
2188c77b71bSopenharmony_ci     */
2198c77b71bSopenharmony_ci    bool IsPlaying();
2208c77b71bSopenharmony_ci
2218c77b71bSopenharmony_ci    /**
2228c77b71bSopenharmony_ci     * @brief Pauses playback.
2238c77b71bSopenharmony_ci     *
2248c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the playback is paused; returns <b>-1</b> otherwise.
2258c77b71bSopenharmony_ci     * @since 1.0
2268c77b71bSopenharmony_ci     * @version 1.0
2278c77b71bSopenharmony_ci     */
2288c77b71bSopenharmony_ci    int32_t Pause();
2298c77b71bSopenharmony_ci
2308c77b71bSopenharmony_ci    /**
2318c77b71bSopenharmony_ci     * @brief Stops playback.
2328c77b71bSopenharmony_ci     *
2338c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the playback is stopped; returns <b>-1</b> otherwise.
2348c77b71bSopenharmony_ci     * @since 1.0
2358c77b71bSopenharmony_ci     * @version 1.0
2368c77b71bSopenharmony_ci     */
2378c77b71bSopenharmony_ci    int32_t Stop();
2388c77b71bSopenharmony_ci
2398c77b71bSopenharmony_ci    /**
2408c77b71bSopenharmony_ci     * @brief Changes the playback position.
2418c77b71bSopenharmony_ci     *
2428c77b71bSopenharmony_ci     * This function can be used during playback or pause.
2438c77b71bSopenharmony_ci     *
2448c77b71bSopenharmony_ci     * @param mSeconds Indicates the target playback position, accurate to second.
2458c77b71bSopenharmony_ci     * @param mode Indicates the player seek mode. For details, see {@link PlayerSeekMode}.
2468c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the playback position is changed; returns <b>-1</b> otherwise.
2478c77b71bSopenharmony_ci     * @since 1.0
2488c77b71bSopenharmony_ci     * @version 1.0
2498c77b71bSopenharmony_ci    */
2508c77b71bSopenharmony_ci    int32_t Rewind(int64_t mSeconds, int32_t mode);
2518c77b71bSopenharmony_ci
2528c77b71bSopenharmony_ci    /**
2538c77b71bSopenharmony_ci     * @brief Sets the volume of the player.
2548c77b71bSopenharmony_ci     *
2558c77b71bSopenharmony_ci     * This function can be used during playback or pause. The value <b>0</b> indicates no sound, and <b>100</b>
2568c77b71bSopenharmony_ci     * indicates the original volume. If no audio device is started or no audio stream exists, the value <b>-1</b>
2578c77b71bSopenharmony_ci     * is returned.
2588c77b71bSopenharmony_ci     *
2598c77b71bSopenharmony_ci     * @param leftVolume Indicates the target volume of the left audio channel to set, ranging from 0 to 300.
2608c77b71bSopenharmony_ci     * @param rightVolume Indicates the target volume of the right audio channel to set, ranging from 0 to 300.
2618c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns <b>-1</b> otherwise.
2628c77b71bSopenharmony_ci     * @since 1.0
2638c77b71bSopenharmony_ci     * @version 1.0
2648c77b71bSopenharmony_ci     */
2658c77b71bSopenharmony_ci    int32_t SetVolume(float leftVolume, float rightVolume);
2668c77b71bSopenharmony_ci
2678c77b71bSopenharmony_ci    /**
2688c77b71bSopenharmony_ci     * @brief Sets a surface for video playback.
2698c77b71bSopenharmony_ci     *
2708c77b71bSopenharmony_ci     * @param surface Indicates the surface to set. For details, see {@link Surface}.
2718c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns <b>-1</b> otherwise.
2728c77b71bSopenharmony_ci     * @since 1.0
2738c77b71bSopenharmony_ci     * @version 1.0
2748c77b71bSopenharmony_ci     */
2758c77b71bSopenharmony_ci#ifndef SURFACE_DISABLED
2768c77b71bSopenharmony_ci    int32_t SetVideoSurface(Surface *surface);
2778c77b71bSopenharmony_ci#endif
2788c77b71bSopenharmony_ci
2798c77b71bSopenharmony_ci    /**
2808c77b71bSopenharmony_ci     * @brief Sets loop playback.
2818c77b71bSopenharmony_ci     *
2828c77b71bSopenharmony_ci     * @param loop Specifies whether to enable loop playback. The value <b>true</b> means to enable loop playback,
2838c77b71bSopenharmony_ci     * and <b>false</b> means to disable loop playback.
2848c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns <b>-1</b> otherwise.
2858c77b71bSopenharmony_ci     * @since 1.0
2868c77b71bSopenharmony_ci     * @version 1.0
2878c77b71bSopenharmony_ci     */
2888c77b71bSopenharmony_ci    int32_t EnableSingleLooping(bool loop);
2898c77b71bSopenharmony_ci
2908c77b71bSopenharmony_ci    /**
2918c77b71bSopenharmony_ci     * @brief Checks whether the player is looping.
2928c77b71bSopenharmony_ci     *
2938c77b71bSopenharmony_ci     * @return Returns <b>true</b> if the player is looping; returns <b>false</b> otherwise.
2948c77b71bSopenharmony_ci     * @since 1.0
2958c77b71bSopenharmony_ci     * @version 1.0
2968c77b71bSopenharmony_ci     */
2978c77b71bSopenharmony_ci    bool IsSingleLooping();
2988c77b71bSopenharmony_ci
2998c77b71bSopenharmony_ci    /**
3008c77b71bSopenharmony_ci     * @brief Obtains the playback position, accurate to millisecond.
3018c77b71bSopenharmony_ci     *
3028c77b71bSopenharmony_ci     * @param time Indicates the playback position.
3038c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the playback position is obtained; returns <b>-1</b> otherwise.
3048c77b71bSopenharmony_ci     * @since 1.0
3058c77b71bSopenharmony_ci     * @version 1.0
3068c77b71bSopenharmony_ci     */
3078c77b71bSopenharmony_ci    int32_t GetCurrentTime(int64_t &time) const;
3088c77b71bSopenharmony_ci
3098c77b71bSopenharmony_ci    /**
3108c77b71bSopenharmony_ci     * @brief Obtains the total duration of media files, in milliseconds.
3118c77b71bSopenharmony_ci     *
3128c77b71bSopenharmony_ci     * @param duration Indicates the total duration of media files.
3138c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the total duration is obtained; returns <b>-1</b> otherwise.
3148c77b71bSopenharmony_ci     * @since 1.0
3158c77b71bSopenharmony_ci     * @version 1.0
3168c77b71bSopenharmony_ci     */
3178c77b71bSopenharmony_ci    int32_t GetDuration(int64_t &duration) const;
3188c77b71bSopenharmony_ci
3198c77b71bSopenharmony_ci    /**
3208c77b71bSopenharmony_ci     * @brief Obtains the width of the video.
3218c77b71bSopenharmony_ci     *
3228c77b71bSopenharmony_ci     * @param videoWidth Indicates the video width.
3238c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the video width is obtained; returns <b>-1</b> otherwise.
3248c77b71bSopenharmony_ci     * @since 1.0
3258c77b71bSopenharmony_ci     * @version 1.0
3268c77b71bSopenharmony_ci     */
3278c77b71bSopenharmony_ci    int32_t GetVideoWidth(int32_t &videoWidth);
3288c77b71bSopenharmony_ci
3298c77b71bSopenharmony_ci    /**
3308c77b71bSopenharmony_ci     * @brief Obtains the height of the video.
3318c77b71bSopenharmony_ci     *
3328c77b71bSopenharmony_ci     * @param videoHeight Indicates the video height.
3338c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the video height is obtained; returns <b>-1</b> otherwise.
3348c77b71bSopenharmony_ci     * @since 1.0
3358c77b71bSopenharmony_ci     * @version 1.0
3368c77b71bSopenharmony_ci     */
3378c77b71bSopenharmony_ci    int32_t GetVideoHeight(int32_t &videoHeight);
3388c77b71bSopenharmony_ci
3398c77b71bSopenharmony_ci    /**
3408c77b71bSopenharmony_ci     * @brief Restores the player to the initial state.
3418c77b71bSopenharmony_ci     *
3428c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the player is restored; returns <b>-1</b> otherwise.
3438c77b71bSopenharmony_ci     * @since 1.0
3448c77b71bSopenharmony_ci     * @version 1.0
3458c77b71bSopenharmony_ci     */
3468c77b71bSopenharmony_ci    int32_t Reset();
3478c77b71bSopenharmony_ci
3488c77b71bSopenharmony_ci    /**
3498c77b71bSopenharmony_ci     * @brief Releases player resources.
3508c77b71bSopenharmony_ci     *
3518c77b71bSopenharmony_ci     * @return Returns <b>0</b> if player resources are released; returns <b>-1</b> otherwise.
3528c77b71bSopenharmony_ci     * @since 1.0
3538c77b71bSopenharmony_ci     * @version 1.0
3548c77b71bSopenharmony_ci     */
3558c77b71bSopenharmony_ci    int32_t Release();
3568c77b71bSopenharmony_ci
3578c77b71bSopenharmony_ci    /**
3588c77b71bSopenharmony_ci     * @brief Registers a listener to receive events and exception notifications from the player.
3598c77b71bSopenharmony_ci     *
3608c77b71bSopenharmony_ci     * @param cb Indicates the listener to register. For details, see {@link PlayerCallback}.
3618c77b71bSopenharmony_ci     * @since 1.0
3628c77b71bSopenharmony_ci     * @version 1.0
3638c77b71bSopenharmony_ci     */
3648c77b71bSopenharmony_ci    void SetPlayerCallback(const std::shared_ptr<PlayerCallback> &cb);
3658c77b71bSopenharmony_ci
3668c77b71bSopenharmony_ci    /**
3678c77b71bSopenharmony_ci     * @brief Obtains the player state.
3688c77b71bSopenharmony_ci     *
3698c77b71bSopenharmony_ci     * @param state Indicates the player state. For details, see {@link PlayerStates}.
3708c77b71bSopenharmony_ci     * @return Returns <b>0</b> if the player state is obtained; returns <b>-1</b> otherwise.
3718c77b71bSopenharmony_ci     * @since 1.0
3728c77b71bSopenharmony_ci     * @version 1.0
3738c77b71bSopenharmony_ci     */
3748c77b71bSopenharmony_ci    int32_t GetPlayerState(int32_t &state) const;
3758c77b71bSopenharmony_ci
3768c77b71bSopenharmony_ci    /**
3778c77b71bSopenharmony_ci     * Sets the playback speed.
3788c77b71bSopenharmony_ci     *
3798c77b71bSopenharmony_ci     * @param speed Indicates the playback speed to set, which support {-128/-64/-32/-16/-8/-4/-2/1/2/4/8/16/32/64/128}
3808c77b71bSopenharmony_ci     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.
3818c77b71bSopenharmony_ci     */
3828c77b71bSopenharmony_ci    int32_t SetPlaybackSpeed(float speed);
3838c77b71bSopenharmony_ci
3848c77b71bSopenharmony_ci    /**
3858c77b71bSopenharmony_ci     * Obtains the playback speed.
3868c77b71bSopenharmony_ci     *
3878c77b71bSopenharmony_ci     * @param speed Indicates the playback speed.
3888c77b71bSopenharmony_ci     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.
3898c77b71bSopenharmony_ci     */
3908c77b71bSopenharmony_ci    int32_t GetPlaybackSpeed(float &speed);
3918c77b71bSopenharmony_ci
3928c77b71bSopenharmony_ci    /**
3938c77b71bSopenharmony_ci     * Sets the audio type.
3948c77b71bSopenharmony_ci     *
3958c77b71bSopenharmony_ci     * @param type Indicates the audio type.
3968c77b71bSopenharmony_ci     * @return Returns {@code 0} if the setting is successful; returns {@code -1} otherwise.
3978c77b71bSopenharmony_ci     */
3988c77b71bSopenharmony_ci    int32_t SetAudioStreamType(int32_t type);
3998c77b71bSopenharmony_ci
4008c77b71bSopenharmony_ci    /**
4018c77b71bSopenharmony_ci     * Obtains the audio type.
4028c77b71bSopenharmony_ci     *
4038c77b71bSopenharmony_ci     * @param type Indicates the audio type.
4048c77b71bSopenharmony_ci     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.
4058c77b71bSopenharmony_ci     */
4068c77b71bSopenharmony_ci    void GetAudioStreamType(int32_t &type);
4078c77b71bSopenharmony_ci
4088c77b71bSopenharmony_ci    /**
4098c77b71bSopenharmony_ci     * set parameter through format, extended interface.
4108c77b71bSopenharmony_ci     *
4118c77b71bSopenharmony_ci     * @param params Indicates the extended-informations. Format see {@link Format}
4128c77b71bSopenharmony_ci     * @return Returns {@code 0} if set parameter successfully; returns {@code -1} otherwise.
4138c77b71bSopenharmony_ci     * @note not support on current version
4148c77b71bSopenharmony_ci     */
4158c77b71bSopenharmony_ci    int32_t SetParameter(const Format &params);
4168c77b71bSopenharmony_ci
4178c77b71bSopenharmony_ciprivate:
4188c77b71bSopenharmony_ci    class PlayerClient;
4198c77b71bSopenharmony_ci    PlayerClient* player_;
4208c77b71bSopenharmony_ci};
4218c77b71bSopenharmony_ci}  // namespace Media
4228c77b71bSopenharmony_ci}  // namespace OHOS
4238c77b71bSopenharmony_ci#endif  // PLAYER_H
424