try to add MAUI support
This commit is contained in:
@@ -20,14 +20,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="LibVLCSharp" Version="3.8.2">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="LibVLCSharp.WPF" Version="3.8.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.0" />
|
||||
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.20" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using Microsoft.Maui.Handlers;
|
||||
using static Microsoft.Maui.ApplicationModel.Permissions;
|
||||
|
||||
namespace TV_Player.MAUI
|
||||
{
|
||||
//public partial class MediaViewerHandler : ViewHandler<MediaViewer, VideoView>
|
||||
//{
|
||||
// VideoView _videoView;
|
||||
// LibVLC _libVLC;
|
||||
// LibVLCSharp.Shared.MediaPlayer _mediaPlayer;
|
||||
|
||||
// protected override VideoView CreatePlatformView() => new VideoView(Context);
|
||||
|
||||
// protected override void ConnectHandler(VideoView nativeView)
|
||||
// {
|
||||
// base.ConnectHandler(nativeView);
|
||||
|
||||
// _libVLC = new LibVLC(enableDebugLogs: true);
|
||||
// _mediaPlayer = new LibVLCSharp.Shared.MediaPlayer(_libVLC)
|
||||
// {
|
||||
// EnableHardwareDecoding = true
|
||||
// };
|
||||
|
||||
// _videoView = nativeView ?? new VideoView(Context);
|
||||
// _videoView.MediaPlayer = _mediaPlayer;
|
||||
|
||||
// HandleUrl(VirtualView.StreamUrl);
|
||||
|
||||
// base.ConnectHandler(nativeView);
|
||||
// }
|
||||
|
||||
// protected override void DisconnectHandler(VideoView nativeView)
|
||||
// {
|
||||
// nativeView.Dispose();
|
||||
// base.DisconnectHandler(nativeView);
|
||||
// }
|
||||
|
||||
// private void HandleUrl(string url)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
|
||||
// if (url.EndsWith("/"))
|
||||
// {
|
||||
// url = url.TrimEnd('/');
|
||||
// }
|
||||
|
||||
// //url = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4";
|
||||
|
||||
// if (!string.IsNullOrEmpty(url))
|
||||
// {
|
||||
// var media = new Media(_libVLC, url, FromType.FromLocation);
|
||||
|
||||
// _mediaPlayer.NetworkCaching = 1500;
|
||||
|
||||
// if (_mediaPlayer.Media != null)
|
||||
// {
|
||||
// _mediaPlayer.Stop();
|
||||
// _mediaPlayer.Media.Dispose();
|
||||
// }
|
||||
|
||||
// _mediaPlayer.Media = media;
|
||||
// _mediaPlayer.Mute = true;
|
||||
|
||||
// _videoView.MediaPlayer.Play();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
namespace TV_Player.MAUI
|
||||
{
|
||||
|
||||
public class MediaViewer : ContentView
|
||||
{
|
||||
//private MediaPlayer _mediaPlayer;
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TV_Player.MAUI
|
||||
{
|
||||
// public partial class MediaViewerHandler
|
||||
// {
|
||||
// public static IPropertyMapper<MediaViewer, MediaViewerHandler> PropertyMapper =
|
||||
// new PropertyMapper<MediaViewer, MediaViewerHandler>()
|
||||
// {
|
||||
// };
|
||||
|
||||
// public static CommandMapper<MediaViewer, MediaViewerHandler> CommandMapper = new(ViewCommandMapper)
|
||||
// {
|
||||
// };
|
||||
|
||||
// public MediaViewerHandler() : base(PropertyMapper, CommandMapper)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
using CommunityToolkit.Maui;
|
||||
|
||||
namespace TV_Player.MAUI
|
||||
{
|
||||
@@ -10,7 +9,6 @@ namespace TV_Player.MAUI
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.UseMauiCommunityToolkitMediaElement()
|
||||
.ConfigureFonts(fonts =>
|
||||
{
|
||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
>
|
||||
|
||||
<StackLayout>
|
||||
<toolkit:MediaElement x:Name="mediaElement"/>
|
||||
<local:MediaViewer x:Name="videoViewer" WidthRequest="300" HeightRequest="300" HorizontalOptions="CenterAndExpand" StreamUrl="{Binding VideoUrl}" />
|
||||
</StackLayout>
|
||||
</ContentPage>
|
||||
|
||||
@@ -67,12 +67,4 @@ public partial class PlayerPage : ContentPage
|
||||
return await client.GetByteArrayAsync(streamUrl);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
// Set the MediaElement source to the temporary file when the page appears
|
||||
mediaElement.Source = tempFilePath;
|
||||
mediaElement.ShouldAutoPlay = true; // Auto-play the media
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
||||
<PackageReference Include="System.IO" Version="4.3.0" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.0" />
|
||||
|
||||
Reference in New Issue
Block a user