1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NAPI_NATIVE_MEDIAPLAYER_HANDLER_IMPL_H 17 #define NAPI_NATIVE_MEDIAPLAYER_HANDLER_IMPL_H 18 19 #include "nweb_native_media_player.h" 20 #include "napi_native_mediaplayer_handler_impl.h" 21 #include "transfer_referenced_count.h" 22 23 namespace OHOS::NWeb { 24 25 class NapiNativeMediaPlayerHandlerImpl : public TransferReferencedCount { 26 public: 27 NapiNativeMediaPlayerHandlerImpl(int32_t nwebId, std::shared_ptr<NWebNativeMediaPlayerHandler> handler); 28 ~NapiNativeMediaPlayerHandlerImpl() = default; 29 30 void HandleStatusChanged(PlaybackStatus status); 31 32 void HandleVolumeChanged(double volume); 33 34 void HandleMutedChanged(bool isMuted); 35 36 void HandlePlaybackRateChanged(double playbackRate); 37 38 void HandleDurationChanged(double duration); 39 40 void HandleTimeUpdate(double playTime); 41 42 void HandleBufferedEndTimeChanged(double bufferedEndTime); 43 44 void HandleEnded(); 45 46 void HandleNetworkStateChanged(NetworkState state); 47 48 void HandleReadyStateChanged(ReadyState state); 49 50 void HandleFullScreenChanged(bool isFullScreen); 51 52 void HandleSeeking(); 53 54 void HandleSeekFinished(); 55 56 void HandleError(MediaError error, const std::string& message); 57 58 void HandleVideoSizeChanged(double width, double height); 59 60 private: 61 int32_t nwebId_ = -1; 62 std::shared_ptr<NWebNativeMediaPlayerHandler> handler_ = nullptr; 63 }; 64 65 } // namespace OHOS::NWeb 66 67 #endif // NAPI_NATIVE_MEDIAPLAYER_HANDLER_IMPL_H 68