diff --git a/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/App.xaml.cs b/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/App.xaml.cs index f5fba4ddb..ff947a62d 100644 --- a/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/App.xaml.cs +++ b/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/App.xaml.cs @@ -15,8 +15,10 @@ public partial class App : Application public App() { this.InitializeComponent(); +#if HAS_UNO Suspending += OnSuspending; Resuming += OnResuming; +#endif } protected Window? MainWindow { get; private set; } @@ -140,6 +142,7 @@ public static void InitializeLogging() /// /// The source of the suspend request. /// Details about the suspend request. +#if HAS_UNO private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); @@ -151,4 +154,5 @@ private void OnResuming(object? sender, object e) { ViewModel?.Resume(); } +#endif } diff --git a/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/LibVLCSharp.Uno.WinUI.Sample.csproj b/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/LibVLCSharp.Uno.WinUI.Sample.csproj index 7d2b6e1a4..5b1279b02 100644 --- a/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/LibVLCSharp.Uno.WinUI.Sample.csproj +++ b/samples/Uno/LibVLCSharp.Uno.WinUI.Sample/LibVLCSharp.Uno.WinUI.Sample.csproj @@ -1,9 +1,9 @@  - - net9.0-android; - net9.0-ios; - + net9.0-android;net9.0-ios + $(TargetFrameworks);net9.0-windows10.0.19041.0 + + None Exe true @@ -28,6 +28,9 @@ enable false + 1.8.260710003 + 10.0.26100.7175 + + 1.7.250909003 + 10.0.22621.756 en 9.0 enable diff --git a/src/LibVLCSharp.Uno/DisplayInformation.cs b/src/LibVLCSharp.Uno/DisplayInformation.cs index 45346bbaa..2422f9656 100644 --- a/src/LibVLCSharp.Uno/DisplayInformation.cs +++ b/src/LibVLCSharp.Uno/DisplayInformation.cs @@ -7,9 +7,24 @@ namespace LibVLCSharp.Uno /// internal class DisplayInformation : IDisplayInformation { + private Microsoft.UI.Xaml.FrameworkElement Owner { get; } + + /// + /// Initializes a new instance of the class. + /// + /// Element whose display scale is used. + public DisplayInformation(Microsoft.UI.Xaml.FrameworkElement owner) + { + Owner = owner; + } + /// /// Gets the scale factor /// +#if WINDOWS + public double ScalingFactor => Owner.XamlRoot?.RasterizationScale ?? 1d; +#else public double ScalingFactor => Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; +#endif } } diff --git a/src/LibVLCSharp.Uno/LibVLCSharp.Uno.csproj b/src/LibVLCSharp.Uno/LibVLCSharp.Uno.csproj index 484ff0c3a..d789052f0 100644 --- a/src/LibVLCSharp.Uno/LibVLCSharp.Uno.csproj +++ b/src/LibVLCSharp.Uno/LibVLCSharp.Uno.csproj @@ -58,7 +58,7 @@ It also contains a VLC MediaPlayerElement for the Uno Platform (UWP, Android, iO - - + + diff --git a/src/LibVLCSharp.Uno/PlaybackControls.UWP.cs b/src/LibVLCSharp.Uno/PlaybackControls.UWP.cs index 6c20c2483..2fedc5b4b 100644 --- a/src/LibVLCSharp.Uno/PlaybackControls.UWP.cs +++ b/src/LibVLCSharp.Uno/PlaybackControls.UWP.cs @@ -21,12 +21,8 @@ protected override void SetToolTip(DependencyObject? element, string? resource, { return; } - var resourceLoader = ResourceLoader; - if (resourceLoader != null) - { - ToolTipService.SetToolTip(element, string.Format(resourceLoader.GetString(resource), - args.Select(arg => resourceLoader.GetString(arg)).Cast().ToArray())); - } + ToolTipService.SetToolTip(element, string.Format(StringResourceLoader.GetString(resource), + args.Select(StringResourceLoader.GetString).Cast().ToArray())); } } } diff --git a/src/LibVLCSharp.Uno/PlaybackControlsBase.cs b/src/LibVLCSharp.Uno/PlaybackControlsBase.cs index fbfa62106..3258d4c8f 100644 --- a/src/LibVLCSharp.Uno/PlaybackControlsBase.cs +++ b/src/LibVLCSharp.Uno/PlaybackControlsBase.cs @@ -53,7 +53,7 @@ public PlaybackControlsBase() { DefaultStyleKey = typeof(PlaybackControls); - Manager = new MediaPlayerElementManager(new DispatcherAdapter(Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread()), new DisplayInformation(), new DisplayRequestAdapter()); + Manager = new MediaPlayerElementManager(new DispatcherAdapter(Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread()), new DisplayInformation(this), new DisplayRequestAdapter()); Manager.Get().AspectRatioChanged += AspectRatioChanged; var autoHideManager = Manager.Get(); autoHideManager.Shown += (sender, e) => VisualStateManager.GoToState(this, ControlPanelFadeInState, true); @@ -684,7 +684,7 @@ private void AddAspectRatioMenu(Button? zoomButton) { var menuItem = new ToggleMenuFlyoutItem { - Text = ResourceLoader.GetString($"{nameof(AspectRatio)}{aspectRatio}"), + Text = StringResourceLoader.GetString($"{nameof(AspectRatio)}{aspectRatio}"), IsChecked = aspectRatio == currentAspectRatio, Command = new ActionCommand(AspectRatioMenuItemClick), CommandParameter = aspectRatio @@ -778,7 +778,7 @@ private void AddTracksMenu(Button? trackButton, TracksManager manager, string av private void AddNoneItem(MenuFlyout menuflyout) { - AddTrack(menuflyout, null, ResourceLoader.GetString("None") ?? string.Empty); + AddTrack(menuflyout, null, StringResourceLoader.GetString("None")); } private void AddTrack(MenuFlyout menuflyout, int? trackId, string trackName) @@ -969,7 +969,7 @@ private void CastButton_Click(object sender, RoutedEventArgs e) { AddCastMenuItem(items, renderer.Name); } - AddCastMenuItem(items, ResourceLoader.GetString("Disconnect"), true); + AddCastMenuItem(items, StringResourceLoader.GetString("Disconnect"), true); ((Button)sender).Flyout = castMenu; } @@ -1034,7 +1034,7 @@ private void ShowError() var errorTextBlock = ErrorTextBlock; if (errorTextBlock != null) { - errorTextBlock.Text = string.Format(ResourceLoader.GetString("Error") ?? string.Empty, Manager.Get().MediaResourceLocator); + errorTextBlock.Text = string.Format(StringResourceLoader.GetString("Error"), Manager.Get().MediaResourceLocator); VisualStateManager.GoToState(this, ErrorState, true); } } diff --git a/src/LibVLCSharp.Uno/StringResourceLoader.cs b/src/LibVLCSharp.Uno/StringResourceLoader.cs new file mode 100644 index 000000000..664168a8c --- /dev/null +++ b/src/LibVLCSharp.Uno/StringResourceLoader.cs @@ -0,0 +1,21 @@ +namespace LibVLCSharp.Uno +{ + internal static class StringResourceLoader + { + private const string ResourceMap = "LibVLCSharp.Uno/Resources"; + +#if WINDOWS + private static readonly Microsoft.Windows.ApplicationModel.Resources.ResourceLoader ResourceLoader = + new Microsoft.Windows.ApplicationModel.Resources.ResourceLoader( + Microsoft.Windows.ApplicationModel.Resources.ResourceLoader.GetDefaultResourceFilePath(), + ResourceMap); + + internal static string GetString(string resource) => ResourceLoader.GetString(resource); +#else + internal static string GetString(string resource) => + Windows.ApplicationModel.Resources.ResourceLoader + .GetForCurrentView(ResourceMap) + .GetString(resource) ?? string.Empty; +#endif + } +} diff --git a/src/LibVLCSharp.Uno/Themes/Generic.xaml b/src/LibVLCSharp.Uno/Themes/Generic.xaml index c7117a531..0cf9c08f4 100644 --- a/src/LibVLCSharp.Uno/Themes/Generic.xaml +++ b/src/LibVLCSharp.Uno/Themes/Generic.xaml @@ -1,6 +1,8 @@ - + + diff --git a/src/LibVLCSharp.Uno/Themes/VideoView.UWP.xaml b/src/LibVLCSharp.Uno/Themes/VideoView.UWP.xaml new file mode 100644 index 000000000..3f55b6f63 --- /dev/null +++ b/src/LibVLCSharp.Uno/Themes/VideoView.UWP.xaml @@ -0,0 +1,15 @@ + + + + diff --git a/src/LibVLCSharp.Uno/VideoView.UWP.cs b/src/LibVLCSharp.Uno/VideoView.UWP.cs index 267809d32..4f89476d1 100644 --- a/src/LibVLCSharp.Uno/VideoView.UWP.cs +++ b/src/LibVLCSharp.Uno/VideoView.UWP.cs @@ -9,6 +9,14 @@ namespace LibVLCSharp.Uno /// public class VideoView : VideoView, IVideoView, IVideoControl { + /// + /// Initializes a new instance of the class. + /// + public VideoView() + { + DefaultStyleKey = typeof(VideoView); + } + /// /// Creates args for event /// diff --git a/src/LibVLCSharp.WinUI/LibVLCSharp.WinUI.csproj b/src/LibVLCSharp.WinUI/LibVLCSharp.WinUI.csproj index fc74fa476..d7646a624 100644 --- a/src/LibVLCSharp.WinUI/LibVLCSharp.WinUI.csproj +++ b/src/LibVLCSharp.WinUI/LibVLCSharp.WinUI.csproj @@ -34,8 +34,8 @@ LibVLC needs to be installed separately, see VideoLAN.LibVLC.Windows. - - + +