1 /* 2 * Copyright (c) 2024 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 ARK_MEDIA_AVSESSION_ADAPTER_H 17 #define ARK_MEDIA_AVSESSION_ADAPTER_H 18 #pragma once 19 20 #include "base/include/ark_web_base_ref_counted.h" 21 #include "base/include/ark_web_types.h" 22 23 namespace OHOS::ArkWeb { 24 25 /*--ark web(source=webcore)--*/ 26 class ArkMediaAVSessionMetadataAdapter : public virtual ArkWebBaseRefCounted { 27 public: 28 /*--ark web()--*/ 29 virtual void SetTitle(const ArkWebString& title) = 0; 30 31 /*--ark web()--*/ 32 virtual ArkWebString GetTitle() = 0; 33 34 /*--ark web()--*/ 35 virtual void SetArtist(const ArkWebString& artist) = 0; 36 37 /*--ark web()--*/ 38 virtual ArkWebString GetArtist() = 0; 39 40 /*--ark web()--*/ 41 virtual void SetAlbum(const ArkWebString& album) = 0; 42 43 /*--ark web()--*/ 44 virtual ArkWebString GetAlbum() = 0; 45 }; 46 47 /*--ark web(source=webcore)--*/ 48 class ArkMediaAVSessionPositionAdapter : public virtual ArkWebBaseRefCounted { 49 public: 50 /*--ark web()--*/ 51 virtual void SetDuration(int64_t duration) = 0; 52 53 /*--ark web()--*/ 54 virtual int64_t GetDuration() = 0; 55 56 /*--ark web()--*/ 57 virtual void SetElapsedTime(int64_t elapsedTime) = 0; 58 59 /*--ark web()--*/ 60 virtual int64_t GetElapsedTime() = 0; 61 62 /*--ark web()--*/ 63 virtual void SetUpdateTime(int64_t updateTime) = 0; 64 65 /*--ark web()--*/ 66 virtual int64_t GetUpdateTime() = 0; 67 }; 68 69 /*--ark web(source=webcore)--*/ 70 class ArkMediaAVSessionCallbackAdapter : public virtual ArkWebBaseRefCounted { 71 public: 72 /*--ark web()--*/ 73 virtual void Play() = 0; 74 75 /*--ark web()--*/ 76 virtual void Pause() = 0; 77 78 /*--ark web()--*/ 79 virtual void Stop() = 0; 80 81 /*--ark web()--*/ 82 virtual void SeekTo(int64_t millisTime) = 0; 83 }; 84 85 /*--ark web(source=webview)--*/ 86 class ArkMediaAVSessionAdapter : public virtual ArkWebBaseRefCounted { 87 public: 88 /*--ark web()--*/ 89 virtual bool CreateAVSession(int32_t type) = 0; 90 91 /*--ark web()--*/ 92 virtual void DestroyAVSession() = 0; 93 94 /*--ark web()--*/ 95 virtual bool RegistCallback(ArkWebRefPtr<ArkMediaAVSessionCallbackAdapter> callbackAdapter) = 0; 96 97 /*--ark web()--*/ 98 virtual bool IsActivated() = 0; 99 100 /*--ark web()--*/ 101 virtual bool Activate() = 0; 102 103 /*--ark web()--*/ 104 virtual void DeActivate() = 0; 105 106 /*--ark web()--*/ 107 virtual void SetMetadata(const ArkWebRefPtr<ArkMediaAVSessionMetadataAdapter> metadata) = 0; 108 109 /*--ark web()--*/ 110 virtual void SetPlaybackState(int32_t state) = 0; 111 112 /*--ark web()--*/ 113 virtual void SetPlaybackPosition(const ArkWebRefPtr<ArkMediaAVSessionPositionAdapter> position) = 0; 114 }; 115 116 } // namespace OHOS::ArkWeb 117 118 #endif // ARK_MEDIA_AVSESSION_ADAPTER_H 119