-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFullScreenPage.xaml.cs
66 lines (53 loc) · 2.2 KB
/
FullScreenPage.xaml.cs
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
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using MElemetModified.Services;
using Mopups.Pages;
using Mopups.Services;
namespace MElemetModified;
public partial class FullScreenPage : PopupPage
{
private readonly DeviceOrientationService deviceOrientationService;
public CurrentVideoState Video { get; set; }
public FullScreenPage(CurrentVideoState currentVideo)
{
Video = currentVideo;
InitializeComponent();
deviceOrientationService = new DeviceOrientationService();
deviceOrientationService.SetDeviceOrientation(displayOrientation: DisplayOrientation.Landscape);
}
protected override void OnAppearing()
{
base.OnAppearing();
mediaElement.Source = Video.VideoUri;
mediaElement.SeekTo(Video.Position);
}
private async void Button_Clicked(object sender, EventArgs e)
{
mediaElement.Source = null;
WeakReferenceMessenger.Default.Send(new NotifyFullScreenClosed(true));
await MopupService.Instance.PopAsync();
}
private void btnChangeAspect_Clicked(object sender, EventArgs e)
{
if (mediaElement.Aspect == Aspect.AspectFit) MainThread.InvokeOnMainThreadAsync(() => mediaElement.Aspect = Aspect.Fill);
else if (mediaElement.Aspect == Aspect.Fill) MainThread.InvokeOnMainThreadAsync(() => mediaElement.Aspect = Aspect.Center);
else if (mediaElement.Aspect == Aspect.Center) MainThread.InvokeOnMainThreadAsync(() => mediaElement.Aspect = Aspect.AspectFit);
}
private void btnChangeOrientation_Clicked(object sender, EventArgs e)
{
switch (DeviceDisplay.Current.MainDisplayInfo.Orientation)
{
case DisplayOrientation.Landscape: deviceOrientationService.SetDeviceOrientation(DisplayOrientation.Portrait); break;
case DisplayOrientation.Portrait: deviceOrientationService.SetDeviceOrientation(DisplayOrientation.Landscape); break;
}
}
}
public class CurrentVideoState
{
public Uri? VideoUri { get; set; }
public TimeSpan Position { get; set; }
}
public class NotifyFullScreenClosed : ValueChangedMessage<bool>
{
public NotifyFullScreenClosed(bool value) : base(value) { }
}