cleanup unused code
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
using DirectShowLib.BDA;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using TV_Player.ViewModels;
|
||||
|
||||
namespace TV_Player
|
||||
@@ -18,5 +15,11 @@ namespace TV_Player
|
||||
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
_tvPlayer = null;
|
||||
base.OnExit(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="LibVLCSharp" Version="3.8.2" />
|
||||
<PackageReference Include="LibVLCSharp" Version="3.8.2">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="LibVLCSharp.WPF" Version="3.8.2" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.0" />
|
||||
<PackageReference Include="WPFMediaKitCore" Version="0.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using LibVLCSharp.Shared;
|
||||
using LibVLCSharp.WPF;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms.Integration;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace TV_Player
|
||||
@@ -13,8 +11,6 @@ namespace TV_Player
|
||||
/// </summary>
|
||||
public partial class VideoPlayer : UserControl
|
||||
{
|
||||
private readonly DirectoryInfo vlcLibDirectory;
|
||||
|
||||
public static readonly DependencyProperty SourceUrlProperty =
|
||||
DependencyProperty.Register(
|
||||
"SourceUrl", // Name of the property
|
||||
@@ -114,7 +110,7 @@ namespace TV_Player
|
||||
|
||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
VideoView.MediaPlayer.Dispose();
|
||||
VideoView.MediaPlayer?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,5 @@ namespace TV_Player.ViewModels
|
||||
control.DataContext = viewModel;
|
||||
_mainViewModel.Control = control;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,19 @@
|
||||
xmlns:local="clr-namespace:TV_Player.MAUI"
|
||||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
||||
Title="PlayerPage"
|
||||
xmlns:vlc="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
|
||||
Loaded="ContentPage_Loaded">
|
||||
|
||||
<StackLayout>
|
||||
<toolkit:MediaElement x:Name="mediaElement"
|
||||
<!--<toolkit:MediaElement x:Name="mediaElement"
|
||||
ShouldAutoPlay="True"
|
||||
ShouldShowPlaybackControls="True"
|
||||
Source="http://ost.da-tv.vip/uPVtzdGJfdG9rZW5dIiwibCI6ImE3MWU3N2ZhIiwicCI6ImE3MWU3N2ZhODM1YjMyMTYiLCJjIjoiNDk3IiwidCI6ImUzNjAwZTEwZmFmMGVhYjhhYWY1YTU2YzRkN2VjZTE5IiwiZCI6IjIzMTQ2IiwiciI6IjIzMDM4IiwibSI6InR2IiwiZHQiOiIwIn0eyJ1IjoiaHR0cDovLzQ1LjkzLjQ2LjI3Ojg4ODcvODM2MS92aWRlby5tM3U4P3Rva2V/video.m3u8"
|
||||
HeightRequest="300"
|
||||
WidthRequest="400"
|
||||
/>
|
||||
/>-->
|
||||
<!--<local:MediaViewer x:Name="libVLCSharpView" WidthRequest="300" HeightRequest="300" HorizontalOptions="CenterAndExpand" StreamUrl="{Binding URLSource,Source={x:Reference MyCustomView}}"/>-->
|
||||
<Button Text="Play" Command="{Binding PlayCommand}" />
|
||||
<vlc:VideoView x:Name="VideoView" Panel.ZIndex="1"/>
|
||||
</StackLayout>
|
||||
|
||||
</ContentPage>
|
||||
|
||||
@@ -1,14 +1,111 @@
|
||||
using LibVLCSharp.Shared;
|
||||
|
||||
namespace TV_Player.MAUI;
|
||||
|
||||
public partial class PlayerPage : ContentPage
|
||||
{
|
||||
public PlayerPage()
|
||||
{
|
||||
this.BindingContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
public static BindableProperty StreamUrlProperty = BindableProperty.Create(nameof(StreamUrl)
|
||||
, typeof(string)
|
||||
, typeof(MediaViewer)
|
||||
, ""
|
||||
, defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
private void ContentPage_Loaded(object sender, EventArgs e)
|
||||
public string StreamUrl
|
||||
{
|
||||
get => (string)GetValue(StreamUrlProperty);
|
||||
set
|
||||
{
|
||||
SetValue(StreamUrlProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
LibVLC _libVLC;
|
||||
MediaPlayer _mediaPlayer;
|
||||
|
||||
|
||||
public VideoPlayer()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_libVLC = new LibVLC(enableDebugLogs: true);
|
||||
_mediaPlayer = new MediaPlayer(_libVLC);
|
||||
|
||||
VideoView.Loaded += (sender, e) =>
|
||||
{
|
||||
VideoView.MediaPlayer = _mediaPlayer;
|
||||
VideoView.MouseLeftButtonDown += VideoView_MouseLeftButtonDown;
|
||||
VideoView.MediaPlayer.EnableMouseInput = false;
|
||||
VideoView.PreviewMouseLeftButtonDown += VideoView_MouseLeftButtonDown;
|
||||
AutoPlay();
|
||||
};
|
||||
Unloaded += VideoPlayer_Unloaded;
|
||||
|
||||
}
|
||||
|
||||
private void VideoView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ToggleOverlay();
|
||||
}
|
||||
|
||||
private void VideoPlayer_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
VideoView.Dispose();
|
||||
}
|
||||
|
||||
|
||||
void PauseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (VideoView.MediaPlayer.IsPlaying)
|
||||
{
|
||||
VideoView.MediaPlayer.Pause();
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoPlay()
|
||||
{
|
||||
if (!VideoView.MediaPlayer.IsPlaying)
|
||||
{
|
||||
|
||||
using (var media = new Media(_libVLC, new Uri(SourceUrl)))
|
||||
VideoView.MediaPlayer.Play(media);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void MyUserControl_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ToggleOverlay();
|
||||
}
|
||||
|
||||
private void MyUserControl_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
ToggleOverlay();
|
||||
}
|
||||
|
||||
private void ToggleOverlay()
|
||||
{
|
||||
if (overlayPanel.Visibility == Visibility.Visible)
|
||||
{
|
||||
HideOverlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowOverlay()
|
||||
{
|
||||
overlayPanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void HideOverlay()
|
||||
{
|
||||
overlayPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
VideoView.MediaPlayer?.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user