• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_MEDIA_PLAYER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_MEDIA_PLAYER_H
18 
19 #include <cstdint>
20 
21 #include "base/memory/ace_type.h"
22 #include "base/utils/noncopyable.h"
23 #include "core/components/video/video_utils.h"
24 #include "core/components_ng/render/render_surface.h"
25 
26 namespace OHOS::Ace::NG {
27 using PositionUpdatedEvent = std::function<void(uint32_t)>;
28 using StateChangedEvent = std::function<void(PlaybackStatus)>;
29 using CommonEvent = std::function<void()>;
30 // MediaPlayer is used to show and play meida
31 class MediaPlayer : public virtual AceType {
32     DECLARE_ACE_TYPE(NG::MediaPlayer, AceType)
33 
34 public:
35     MediaPlayer() = default;
36     ~MediaPlayer() override = default;
37 
38     static RefPtr<MediaPlayer> Create();
39 
CreateMediaPlayer()40     virtual void CreateMediaPlayer() {}
41 
ResetMediaPlayer()42     virtual void ResetMediaPlayer() {}
43 
IsMediaPlayerValid()44     virtual bool IsMediaPlayerValid()
45     {
46         return false;
47     }
48 
SetVolume(float leftVolume,float rightVolume)49     virtual void SetVolume(float leftVolume, float rightVolume) {}
50 
SetSource(const std::string &)51     virtual bool SetSource(const std::string& /*src*/)
52     {
53         return false;
54     }
55 
SetRenderSurface(const RefPtr<RenderSurface> & renderSurface)56     virtual void SetRenderSurface(const RefPtr<RenderSurface>& renderSurface) {}
57 
RegisterMediaPlayerEvent(PositionUpdatedEvent && positionUpdatedEvent,StateChangedEvent && stateChangedEvent,CommonEvent && errorEvent,CommonEvent && resolutionChangeEvent,CommonEvent && startRenderFrameEvent)58     virtual void RegisterMediaPlayerEvent(PositionUpdatedEvent&& positionUpdatedEvent,
59         StateChangedEvent&& stateChangedEvent, CommonEvent&& errorEvent, CommonEvent&& resolutionChangeEvent,
60         CommonEvent&& startRenderFrameEvent)
61     {}
62 
GetDuration(int32_t &)63     virtual int32_t GetDuration(int32_t& /*duration*/)
64     {
65         return -1;
66     }
67 
GetVideoWidth()68     virtual int32_t GetVideoWidth()
69     {
70         return -1;
71     }
72 
GetVideoHeight()73     virtual int32_t GetVideoHeight()
74     {
75         return -1;
76     }
77 
SetLooping(bool)78     virtual int32_t SetLooping(bool /*loop*/)
79     {
80         return -1;
81     }
82 
SetPlaybackSpeed(float)83     virtual int32_t SetPlaybackSpeed(float /*speed*/)
84     {
85         return -1;
86     }
87 
SetSurface()88     virtual int32_t SetSurface()
89     {
90         return -1;
91     }
92 
PrepareAsync()93     virtual int32_t PrepareAsync()
94     {
95         return -1;
96     }
97 
IsPlaying()98     virtual bool IsPlaying()
99     {
100         return false;
101     }
102 
Play()103     virtual int32_t Play()
104     {
105         return -1;
106     }
107 
Pause()108     virtual int32_t Pause()
109     {
110         return -1;
111     }
112 
Stop()113     virtual int32_t Stop()
114     {
115         return -1;
116     }
117 
Seek(int32_t,SeekMode)118     virtual int32_t Seek(int32_t /*mSeconds*/, SeekMode /*mode*/)
119     {
120         return -1;
121     }
FullScreenChange(bool isFullScreen)122     virtual int32_t FullScreenChange(bool isFullScreen)
123     {
124         return -1;
125     }
126 
127 protected:
128 
129     ACE_DISALLOW_COPY_AND_MOVE(MediaPlayer);
130 };
131 } // namespace OHOS::Ace::NG
132 
133 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_MEDIA_PLAYER_H
134