-
Notifications
You must be signed in to change notification settings - Fork 493
Expand file tree
/
Copy pathIMediaElement.shared.cs
More file actions
180 lines (148 loc) · 5.48 KB
/
IMediaElement.shared.cs
File metadata and controls
180 lines (148 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using CommunityToolkit.Maui.Views;
using Microsoft.Maui;
namespace CommunityToolkit.Maui.Core;
/// <summary>
/// With MediaElement you can play multimedia inside your app.
/// </summary>
public interface IMediaElement : IView, IAsynchronousMediaElementHandler
{
/// <summary>
/// Occurs when <see cref="CurrentState"/> changed.
/// </summary>
event EventHandler<MediaStateChangedEventArgs> StateChanged;
/// <summary>
/// Occurs when the <see cref="Position"/> changes;
/// </summary>
event EventHandler<MediaPositionChangedEventArgs> PositionChanged;
/// <summary>
/// Gets the media aspect ratio.
/// </summary>
/// <remarks>Not functional for non-visual media.</remarks>
Aspect Aspect { get; }
/// <summary>
/// The current state of the <see cref="MediaElement"/>.
/// </summary>
MediaElementState CurrentState { get; }
/// <summary>
/// Gets the full screen state of the media element.
/// </summary>
MediaElementScreenState FullScreenState { get; }
/// <summary>
/// Gets the height (in pixels) of the loaded media in pixels.
/// </summary>
/// <remarks>Not reported for non-visual media.</remarks>
int MediaHeight { get; internal set; }
/// <summary>
/// Gets the width (in pixels) of the loaded media in pixels.
/// </summary>
/// <remarks>Not reported for non-visual media.</remarks>
int MediaWidth { get; internal set; }
/// <summary>
/// The current position of the playing media.
/// </summary>
TimeSpan Position { get; internal set; }
/// <summary>
/// Gets total duration of the loaded media.
/// </summary>
/// <remarks>Might not be available for some types, like live streams.</remarks>
TimeSpan Duration { get; set; }
/// <summary>
/// Gets or sets whether the media should start playing as soon as it's loaded.
/// </summary>
bool ShouldAutoPlay { get; set; }
/// <summary>
/// Gets or sets if the media playback will restart from the beginning when it reaches the end.
/// </summary>
bool ShouldLoopPlayback { get; set; }
/// <summary>
/// Gets or sets if media playback will prevent the device display from going to sleep.
/// </summary>
/// <remarks>If media is paused, stopped or has completed playing, the display will turn off.</remarks>
bool ShouldKeepScreenOn { get; set; }
/// <summary>
/// Gets or sets if audio should be muted.
/// </summary>
bool ShouldMute { get; set; }
/// <summary>
/// Gets or sets whether the player should show the platform playback controls.
/// </summary>
bool ShouldShowPlaybackControls { get; set; }
/// <summary>
/// Gets or sets the source of the media to play.
/// </summary>
MediaSource? Source { get; set; }
/// <summary>
/// Gets or sets the speed with which the media should be played.
/// </summary>
/// <remarks>A value of 1 means normal speed.
/// Anything more than 1 is faster speed, anything less than 1 is slower speed.</remarks>
double Speed { get; set; }
/// <summary>
/// Gets or sets the volume of the audio for the media.
/// </summary>
/// <remarks>A value of 1 indicates full volume, 0 is silence.</remarks>
double Volume { get; set; }
/// <summary>
/// Gets or sets the title of the media.
/// </summary>
string MetadataTitle { get; set; }
/// <summary>
/// Gets or sets the artist of the media.
/// </summary>
string MetadataArtist { get; set; }
/// <summary>
/// Gets or sets the artwork Image Url.
/// </summary>
string MetadataArtworkUrl { get; set; }
/// <summary>
/// Occurs when the <see cref="FullScreenState"/> changes.
/// </summary>
event EventHandler<ScreenStateChangedEventArgs> ScreenStateChanged;
/// <summary>
/// Occurs when the media has ended playing successfully.
/// </summary>
/// <remarks>This does not trigger when the media has failed during playback.</remarks>
void MediaEnded();
/// <summary>
/// Occurs when the media has failed loading.
/// </summary>
/// <param name="args">Event arguments containing extra information about this event.</param>
void MediaFailed(MediaFailedEventArgs args);
/// <summary>
/// Occurs when the media has been loaded and is ready to play.
/// </summary>
void MediaOpened();
/// <summary>
/// Pauses the currently playing media.
/// </summary>
void Pause();
/// <summary>
/// Starts playing the loaded media.
/// </summary>
void Play();
/// <summary>
/// Seek to a specific position in the currently playing media.
/// </summary>
/// <param name="position">The requested position to seek to.</param>
/// <param name="token"><see cref="CancellationToken"/>.</param>
/// <remarks>If <paramref name="position"/> is outside of the range of the current media item, nothing will happen.</remarks>
Task SeekTo(TimeSpan position, CancellationToken token = default);
/// <summary>
/// Stops playing the currently playing media and resets the <see cref="Position"/>.
/// </summary>
void Stop();
/// <summary>
/// Triggers the <see cref="MediaElement.SeekCompleted"/> event.
/// </summary>
internal void SeekCompleted();
/// <summary>
/// Triggers a <see cref="CurrentState"/> change.
/// </summary>
/// <param name="newState">The new state the <see cref="MediaElement"/> transitioned to.</param>
internal void CurrentStateChanged(MediaElementState newState);
/// <summary>
/// Triggers a <see cref="FullScreenState"/> change. Intended to be called by platform-specific handlers or managers when the fullscreen state changes.
/// </summary>
/// <param name="newState">The new fullscreen state the <see cref="MediaElement"/> transitioned to.</param>
internal void FullScreenChanged(MediaElementScreenState newState);
}