From 1eac163ed0cf866657345418e3cf727a777704dd Mon Sep 17 00:00:00 2001 From: sharpshooter Date: Thu, 26 Aug 2021 12:26:49 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E5=85=83=E6=95=B0=E6=8D=AE=E5=AF=B9?= =?UTF-8?q?=E5=A4=96=E6=8E=A5=E5=8F=A3=20Signed-off-by:=20sharpshooter=5Ft?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/js/media/include/avmetadatahelper.h | 244 ++++++++++++++++++ .../kits/js/media/include/avsharedmemory.h | 71 +++++ 2 files changed, 315 insertions(+) create mode 100644 interfaces/kits/js/media/include/avmetadatahelper.h create mode 100644 interfaces/kits/js/media/include/avsharedmemory.h diff --git a/interfaces/kits/js/media/include/avmetadatahelper.h b/interfaces/kits/js/media/include/avmetadatahelper.h new file mode 100644 index 000000000..954b4c4c6 --- /dev/null +++ b/interfaces/kits/js/media/include/avmetadatahelper.h @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AVMETADATAHELPER_H +#define AVMETADATAHELPER_H + +#include +#include +#include +#include "refbase.h" +#include "display_type.h" +#include "nocopyable.h" +#include "avsharedmemory.h" + +namespace OHOS { +namespace Media { +/** + * @attention This is the stub for image module, the complete definition must be provided by the image module. + */ +class PixelMap : public RefBase { + PixelMap() = default; + ~PixelMap() = default; +}; + +/** + * @brief Enumerates avmetadata usage. + */ +enum AVMetadataUsage : int32_t { + /** + * Indicates that the avmetadahelper's instance will only be used for resolving the + * metadata from the given media resource. + */ + AV_META_USAGE_META_ONLY, + /** + * Indicates that the avmetadahelper's instance will be used for fetching the video frame + * and resolving metadata from the given media resource. + */ + AV_META_USAGE_PIXEL_MAP, +}; + +/** + * @brief Enumerates avmetadata's metadata key. + */ +enum AVMetadataCode : int32_t { + /** + * The metadata key to retrieve the information about the album title + * of the media source. + */ + AV_KEY_ALBUM = 0, + /** + * The metadata key to retrieve the information about the performers or + * artist associated with the media source. + */ + AV_KEY_ALBUMARTIST = 1, + /** + * The metadata key to retrieve the information about the artist of + * the media source. + */ + AV_KEY_ARTIST = 2, + /** + * The metadata key to retrieve the information about the author of + * the media source. + */ + AV_KEY_AUTHOR = 3, + /** + * The metadata key to retrieve the information about the composer of + * the media source. + */ + AV_KEY_COMPOSER = 12, + /** + * The metadata key to retrieve the playback duration of the media source. + */ + AV_KEY_DURATION = 15, + /** + * The metadata key to retrieve the content type or genre of the data + * source. + */ + AV_KEY_GENRE = 18, + /** + * If this key exists the media contains audio content. + */ + AV_KEY_HAS_AUDIO = 19, + /** + * If this key exists the media contains video content. + */ + AV_KEY_HAS_VIDEO = 21, + /** + * The metadata key to retrieve the mime type of the media source. Some + * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb", + * etc. + */ + AV_KEY_MIMETYPE = 29, + /** + * The metadata key to retrieve the number of tracks, such as audio, video, + * text, in the media source, such as a mp4 or 3gpp file. + */ + AV_KEY_NUM_TRACKS = 30, + /** + * This key retrieves the sample rate, if available. + */ + AV_KEY_SAMPLERATE = 31, + /** + * The metadata key to retrieve the media source title. + */ + AV_KEY_TITLE = 33, + /** + * If the media contains video, this key retrieves its height. + */ + AV_KEY_VIDEO_HEIGHT = 35, + /** + * If the media contains video, this key retrieves its width. + */ + AV_KEY_VIDEO_WIDTH = 37, +}; + +/** + * @brief Enumerates avmetadata's query option. + */ +enum AVMetadataQueryOption : int32_t { + /** + * This option is used to fetch a key frame from the given media + * resource that is located right after or at the given time. + */ + AV_META_QUERY_NEXT_SYNC, + /** + * This option is used to fetch a key frame from the given media + * resource that is located right before or at the given time. + */ + AV_META_QUERY_PREVIOUS_SYNC, + /** + * This option is used to fetch a key frame from the given media + * resource that is located closest to or at the given time. + */ + AV_META_QUERY_CLOSEST_SYNC, + /** + * This option is used to fetch a frame (maybe not keyframe) from + * the given media resource that is located closest to or at the given time. + */ + AV_META_QUERY_CLOSEST, +}; + +/** + * @brief Provides the definition of the returned pixelmap's configuration + */ +struct PixelMapParams { + /** + * Expected pixelmap's width, -1 means to keep consistent with the + * original dimensions of the given video resource. + */ + int32_t dstWidth = -1; + /** + * Expected pixelmap's width, -1 means to keep consistent with the + * original dimensions of the given video resource. + */ + int32_t dstHeight = -1; + /** + * Expected pixelmap's color format. + */ + int32_t colorFormat = PixelFormat::PIXEL_FMT_RGB_565; +}; + +/** + * @brief Provides the interfaces to resolve metadata or fetch frame + * from a given media resource. + */ +class AVMetadataHelper { +public: + virtual ~AVMetadataHelper() = default; + + /** + * Set the media source uri to use. Calling this method before the reset + * of the methods in this class. This method maybe time consuming. + * @param uri the URI of input media source. + * @param usage indicates which scene the avmedatahelper's instance will + * be used to, see {@link AVMetadataUsage}. If the usage need to be changed, + * this method must be called again. + * @return Returns {@link MSERR_OK} if the setting is successful; returns + * an error code otherwise. + */ + virtual int32_t SetSource(const std::string &uri, int32_t usage = AVMetadataUsage::AV_META_USAGE_PIXEL_MAP) = 0; + + /** + * Retrieve the meta data associated with the specified key. This method must be + * called after the SetSource. + * @param key One of the constants listed above at the definition of {@link AVMetadataCode}. + * @return Returns the meta data value associate with the given key code on + * success; empty string on failure. + */ + virtual std::string ResolveMetadata(int32_t key) = 0; + + /** + * Retrieve all meta data within the listed above at the definition of {@link AVMetadataCode}. + * This method must be called after the SetSource. + * @return Returns the meta data values on success; empty string on failure. + */ + virtual std::unordered_map ResolveMetadata() = 0; + + /** + * Fetch a representative video frame near a given timestamp by considering the given + * option if possible, and return a pixelmap with given parameters. This method must be + * called after the SetSource. + * @param timeMs The time position in microseconds where the frame will be fetched. + * When fetching the frame at the given time position, there is no guarantee that + * the video source has a frame located at the position. When this happens, a frame + * nearby will be returned. If timeUs is negative, time position and option will ignored, + * and any frame that the implementation considers as representative may be returned. + * @param option the hint about how to fetch a frame, see {@link AVMetadataQueryOption} + * @param param the desired configuration of returned pixelmap, see {@link PixelMapParams}. + * @return Returns a pixelmap containing a scaled video frame, which can be null, if such a + * frame cannot be fetched. + */ + virtual sptr FetchFrameAtTime(int64_t timeUs, int32_t option, PixelMapParams param) = 0; + + /** + * Release the internel resource. After this method called, the avmetadatahelper instance + * can not be used again. + */ + virtual void Release() = 0; +}; + +class __attribute__((visibility("default"))) AVMetadataHelperFactory { +public: + static std::shared_ptr CreateAVMetadataHelper(); + +private: + AVMetadataHelperFactory() = default; + ~AVMetadataHelperFactory() = default; +}; +} +} + +#endif \ No newline at end of file diff --git a/interfaces/kits/js/media/include/avsharedmemory.h b/interfaces/kits/js/media/include/avsharedmemory.h new file mode 100644 index 000000000..7805b0240 --- /dev/null +++ b/interfaces/kits/js/media/include/avsharedmemory.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AVSHAREDMEMORY_H +#define AVSHAREDMEMORY_H + +#include +#include + +namespace OHOS { +namespace Media { +/** + * @brief Provides a unified interface to implement convenient memory sharing + * mechanism. For those platforms that do not support multi-process, it may + * simply encapsulate ordinary memory blocks, not really multi-process shareable memory. + */ +class __attribute__((visibility("default"))) AVSharedMemory { +public: + virtual ~AVSharedMemory() = default; + + /** + * @brief Enumerates the flag bits used to create a new shared memory. + */ + enum Flags : uint32_t { + /** + * This flag bit indicates that the remote process is allowed to read and write + * the shared memory. If no flags are specified, this is the default memory + * sharing policy. If the FLAGS_READ_ONLY bit is set, this flag bit is ignored. + */ + FLAGS_READ_WRITE = 0x1, + /** + * For platforms that support multiple processes, this flag bit indicates that the + * remote process can only read data in the shared memory. If this flag is not set, + * the remote process has both read and write permissions by default. Adding this + * flag does not affect the process that creates the memory, which always has the + * read and write permission on the shared memory. For platforms that do not support + * multi-processes, the memory read and write permission control capability may + * not be available. In this case, this flag is invalid. + */ + FLAGS_READ_ONLY = 0x2, + }; + + /** + * @brief Create a new AVSharedMemory instance containing a chunk of shared memory. + * @param size the desired shared memory size in bytes. + * @param flags the flag to control the memory attributes, see {@link Flags} + * @param name the optional argument used to facilitate debug info displaying. + * @return The AVSharedMemory instance containing a chunk of shared memory + */ + static std::shared_ptr Create(int32_t size, uint32_t flags, const std::string &name = ""); + + virtual uint8_t *GetBase() = 0; + virtual int32_t GetSize() = 0; + virtual uint32_t GetFlags() = 0; +}; +} +} + +#endif \ No newline at end of file -- Gitee From 0a4cda30a0a0b84146f2c7c317888ba8ceaef58a Mon Sep 17 00:00:00 2001 From: sharpshooter Date: Thu, 26 Aug 2021 12:40:44 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20inte?= =?UTF-8?q?rfaces/kits/js/media/include/avmetadatahelper.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/js/media/include/avmetadatahelper.h | 244 ------------------ 1 file changed, 244 deletions(-) delete mode 100644 interfaces/kits/js/media/include/avmetadatahelper.h diff --git a/interfaces/kits/js/media/include/avmetadatahelper.h b/interfaces/kits/js/media/include/avmetadatahelper.h deleted file mode 100644 index 954b4c4c6..000000000 --- a/interfaces/kits/js/media/include/avmetadatahelper.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AVMETADATAHELPER_H -#define AVMETADATAHELPER_H - -#include -#include -#include -#include "refbase.h" -#include "display_type.h" -#include "nocopyable.h" -#include "avsharedmemory.h" - -namespace OHOS { -namespace Media { -/** - * @attention This is the stub for image module, the complete definition must be provided by the image module. - */ -class PixelMap : public RefBase { - PixelMap() = default; - ~PixelMap() = default; -}; - -/** - * @brief Enumerates avmetadata usage. - */ -enum AVMetadataUsage : int32_t { - /** - * Indicates that the avmetadahelper's instance will only be used for resolving the - * metadata from the given media resource. - */ - AV_META_USAGE_META_ONLY, - /** - * Indicates that the avmetadahelper's instance will be used for fetching the video frame - * and resolving metadata from the given media resource. - */ - AV_META_USAGE_PIXEL_MAP, -}; - -/** - * @brief Enumerates avmetadata's metadata key. - */ -enum AVMetadataCode : int32_t { - /** - * The metadata key to retrieve the information about the album title - * of the media source. - */ - AV_KEY_ALBUM = 0, - /** - * The metadata key to retrieve the information about the performers or - * artist associated with the media source. - */ - AV_KEY_ALBUMARTIST = 1, - /** - * The metadata key to retrieve the information about the artist of - * the media source. - */ - AV_KEY_ARTIST = 2, - /** - * The metadata key to retrieve the information about the author of - * the media source. - */ - AV_KEY_AUTHOR = 3, - /** - * The metadata key to retrieve the information about the composer of - * the media source. - */ - AV_KEY_COMPOSER = 12, - /** - * The metadata key to retrieve the playback duration of the media source. - */ - AV_KEY_DURATION = 15, - /** - * The metadata key to retrieve the content type or genre of the data - * source. - */ - AV_KEY_GENRE = 18, - /** - * If this key exists the media contains audio content. - */ - AV_KEY_HAS_AUDIO = 19, - /** - * If this key exists the media contains video content. - */ - AV_KEY_HAS_VIDEO = 21, - /** - * The metadata key to retrieve the mime type of the media source. Some - * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb", - * etc. - */ - AV_KEY_MIMETYPE = 29, - /** - * The metadata key to retrieve the number of tracks, such as audio, video, - * text, in the media source, such as a mp4 or 3gpp file. - */ - AV_KEY_NUM_TRACKS = 30, - /** - * This key retrieves the sample rate, if available. - */ - AV_KEY_SAMPLERATE = 31, - /** - * The metadata key to retrieve the media source title. - */ - AV_KEY_TITLE = 33, - /** - * If the media contains video, this key retrieves its height. - */ - AV_KEY_VIDEO_HEIGHT = 35, - /** - * If the media contains video, this key retrieves its width. - */ - AV_KEY_VIDEO_WIDTH = 37, -}; - -/** - * @brief Enumerates avmetadata's query option. - */ -enum AVMetadataQueryOption : int32_t { - /** - * This option is used to fetch a key frame from the given media - * resource that is located right after or at the given time. - */ - AV_META_QUERY_NEXT_SYNC, - /** - * This option is used to fetch a key frame from the given media - * resource that is located right before or at the given time. - */ - AV_META_QUERY_PREVIOUS_SYNC, - /** - * This option is used to fetch a key frame from the given media - * resource that is located closest to or at the given time. - */ - AV_META_QUERY_CLOSEST_SYNC, - /** - * This option is used to fetch a frame (maybe not keyframe) from - * the given media resource that is located closest to or at the given time. - */ - AV_META_QUERY_CLOSEST, -}; - -/** - * @brief Provides the definition of the returned pixelmap's configuration - */ -struct PixelMapParams { - /** - * Expected pixelmap's width, -1 means to keep consistent with the - * original dimensions of the given video resource. - */ - int32_t dstWidth = -1; - /** - * Expected pixelmap's width, -1 means to keep consistent with the - * original dimensions of the given video resource. - */ - int32_t dstHeight = -1; - /** - * Expected pixelmap's color format. - */ - int32_t colorFormat = PixelFormat::PIXEL_FMT_RGB_565; -}; - -/** - * @brief Provides the interfaces to resolve metadata or fetch frame - * from a given media resource. - */ -class AVMetadataHelper { -public: - virtual ~AVMetadataHelper() = default; - - /** - * Set the media source uri to use. Calling this method before the reset - * of the methods in this class. This method maybe time consuming. - * @param uri the URI of input media source. - * @param usage indicates which scene the avmedatahelper's instance will - * be used to, see {@link AVMetadataUsage}. If the usage need to be changed, - * this method must be called again. - * @return Returns {@link MSERR_OK} if the setting is successful; returns - * an error code otherwise. - */ - virtual int32_t SetSource(const std::string &uri, int32_t usage = AVMetadataUsage::AV_META_USAGE_PIXEL_MAP) = 0; - - /** - * Retrieve the meta data associated with the specified key. This method must be - * called after the SetSource. - * @param key One of the constants listed above at the definition of {@link AVMetadataCode}. - * @return Returns the meta data value associate with the given key code on - * success; empty string on failure. - */ - virtual std::string ResolveMetadata(int32_t key) = 0; - - /** - * Retrieve all meta data within the listed above at the definition of {@link AVMetadataCode}. - * This method must be called after the SetSource. - * @return Returns the meta data values on success; empty string on failure. - */ - virtual std::unordered_map ResolveMetadata() = 0; - - /** - * Fetch a representative video frame near a given timestamp by considering the given - * option if possible, and return a pixelmap with given parameters. This method must be - * called after the SetSource. - * @param timeMs The time position in microseconds where the frame will be fetched. - * When fetching the frame at the given time position, there is no guarantee that - * the video source has a frame located at the position. When this happens, a frame - * nearby will be returned. If timeUs is negative, time position and option will ignored, - * and any frame that the implementation considers as representative may be returned. - * @param option the hint about how to fetch a frame, see {@link AVMetadataQueryOption} - * @param param the desired configuration of returned pixelmap, see {@link PixelMapParams}. - * @return Returns a pixelmap containing a scaled video frame, which can be null, if such a - * frame cannot be fetched. - */ - virtual sptr FetchFrameAtTime(int64_t timeUs, int32_t option, PixelMapParams param) = 0; - - /** - * Release the internel resource. After this method called, the avmetadatahelper instance - * can not be used again. - */ - virtual void Release() = 0; -}; - -class __attribute__((visibility("default"))) AVMetadataHelperFactory { -public: - static std::shared_ptr CreateAVMetadataHelper(); - -private: - AVMetadataHelperFactory() = default; - ~AVMetadataHelperFactory() = default; -}; -} -} - -#endif \ No newline at end of file -- Gitee From 9236ba55ad70904371e5f7571238d7cb283ba7c6 Mon Sep 17 00:00:00 2001 From: sharpshooter Date: Thu, 26 Aug 2021 12:40:49 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20inte?= =?UTF-8?q?rfaces/kits/js/media/include/avsharedmemory.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/js/media/include/avsharedmemory.h | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 interfaces/kits/js/media/include/avsharedmemory.h diff --git a/interfaces/kits/js/media/include/avsharedmemory.h b/interfaces/kits/js/media/include/avsharedmemory.h deleted file mode 100644 index 7805b0240..000000000 --- a/interfaces/kits/js/media/include/avsharedmemory.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AVSHAREDMEMORY_H -#define AVSHAREDMEMORY_H - -#include -#include - -namespace OHOS { -namespace Media { -/** - * @brief Provides a unified interface to implement convenient memory sharing - * mechanism. For those platforms that do not support multi-process, it may - * simply encapsulate ordinary memory blocks, not really multi-process shareable memory. - */ -class __attribute__((visibility("default"))) AVSharedMemory { -public: - virtual ~AVSharedMemory() = default; - - /** - * @brief Enumerates the flag bits used to create a new shared memory. - */ - enum Flags : uint32_t { - /** - * This flag bit indicates that the remote process is allowed to read and write - * the shared memory. If no flags are specified, this is the default memory - * sharing policy. If the FLAGS_READ_ONLY bit is set, this flag bit is ignored. - */ - FLAGS_READ_WRITE = 0x1, - /** - * For platforms that support multiple processes, this flag bit indicates that the - * remote process can only read data in the shared memory. If this flag is not set, - * the remote process has both read and write permissions by default. Adding this - * flag does not affect the process that creates the memory, which always has the - * read and write permission on the shared memory. For platforms that do not support - * multi-processes, the memory read and write permission control capability may - * not be available. In this case, this flag is invalid. - */ - FLAGS_READ_ONLY = 0x2, - }; - - /** - * @brief Create a new AVSharedMemory instance containing a chunk of shared memory. - * @param size the desired shared memory size in bytes. - * @param flags the flag to control the memory attributes, see {@link Flags} - * @param name the optional argument used to facilitate debug info displaying. - * @return The AVSharedMemory instance containing a chunk of shared memory - */ - static std::shared_ptr Create(int32_t size, uint32_t flags, const std::string &name = ""); - - virtual uint8_t *GetBase() = 0; - virtual int32_t GetSize() = 0; - virtual uint32_t GetFlags() = 0; -}; -} -} - -#endif \ No newline at end of file -- Gitee From 9c5e9aa7af27da0071983743804b4623398c0606 Mon Sep 17 00:00:00 2001 From: sharpshooter Date: Thu, 26 Aug 2021 12:41:46 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9player=20napi=20Signed-of?= =?UTF-8?q?f-by:=20sharpshooter=5Ft=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/js/media/include/audio_player_napi.h | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/interfaces/kits/js/media/include/audio_player_napi.h b/interfaces/kits/js/media/include/audio_player_napi.h index 97fcbf37e..96e4d93ef 100644 --- a/interfaces/kits/js/media/include/audio_player_napi.h +++ b/interfaces/kits/js/media/include/audio_player_napi.h @@ -17,6 +17,7 @@ #define AUDIO_PLAYER_NAPI_H_ #include "player.h" +#include "media_errors.h" #include "napi/native_api.h" #include "napi/native_node_api.h" @@ -24,23 +25,8 @@ namespace OHOS { namespace Media { class AudioPlayerNapi { public: - AudioPlayerNapi(); - ~AudioPlayerNapi(); - static napi_value Init(napi_env env, napi_value exports); - napi_ref errorCallback_ = nullptr; // error - napi_ref playCallback_ = nullptr; // started - napi_ref pauseCallback_ = nullptr; // paused - napi_ref stopCallback_ = nullptr; // stopped - napi_ref resetCallback_ = nullptr; // idle - napi_ref dataLoadCallback_ = nullptr; // prepared - napi_ref finishCallback_ = nullptr; // endofstream - napi_ref timeUpdateCallback_ = nullptr; // seekdone - napi_ref volumeChangeCallback_ = nullptr; - - void SetCurrentState(PlayerStates state); - private: static napi_value Constructor(napi_env env, napi_callback_info info); static void Destructor(napi_env env, void *nativeObject, void *finalize); @@ -53,7 +39,6 @@ private: static napi_value SetVolume(napi_env env, napi_callback_info info); static napi_value Release(napi_env env, napi_callback_info info); static napi_value On(napi_env env, napi_callback_info info); - static napi_value SetSrc(napi_env env, napi_callback_info info); static napi_value GetSrc(napi_env env, napi_callback_info info); static napi_value SetLoop(napi_env env, napi_callback_info info); @@ -61,11 +46,9 @@ private: static napi_value GetCurrentTime(napi_env env, napi_callback_info info); static napi_value GetDuration(napi_env env, napi_callback_info info); static napi_value GetState(napi_env env, napi_callback_info info); - static void SendErrorCallback(napi_env env, napi_ref &callbackRef, - const std::string &errCode, const std::string &errType); - - void SaveCallbackReference(napi_env env, AudioPlayerNapi &audioPlayer, - const std::string &callbackName, napi_value callback) const; + void ErrorCallback(napi_env env, MediaServiceExtErrCode errCode); + AudioPlayerNapi(); + ~AudioPlayerNapi(); static napi_ref constructor_; napi_env env_ = nullptr; @@ -73,8 +56,6 @@ private: std::shared_ptr nativePlayer_ = nullptr; std::shared_ptr callbackNapi_ = nullptr; std::string uri_ = ""; - PlayerStates currentState_ = PLAYER_IDLE; - bool isRelease = false; }; } // namespace Media } // namespace OHOS -- Gitee