Added BackCommand to video player window
This commit is contained in:
@@ -6,13 +6,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
>
|
||||
|
||||
Unloaded="UserControl_Unloaded">
|
||||
<Grid>
|
||||
<Grid x:Name="videoPlayer">
|
||||
<vlc:VideoView x:Name="VideoView" Panel.ZIndex="1">
|
||||
<StackPanel Panel.ZIndex="2" Opacity="0.9"
|
||||
IsHitTestVisible="True"
|
||||
<StackPanel Panel.ZIndex="10" IsHitTestVisible="True" Background="#01FFFFFF"
|
||||
HorizontalAlignment="Stretch" MouseLeftButtonDown="MyUserControl_MouseDown"
|
||||
TouchDown="MyUserControl_TouchDown" >
|
||||
<Grid x:Name="overlayPanel" Visibility="Collapsed" >
|
||||
@@ -22,10 +19,10 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0" Content="Pause" HorizontalAlignment="Stretch" Click="PauseButton_Click" />
|
||||
<Button Grid.Column="0" Content="Back" HorizontalAlignment="Stretch" Command="{Binding BackCommand}" />
|
||||
<Button Grid.Column="1" Content="Pause" HorizontalAlignment="Stretch" Click="PauseButton_Click" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</vlc:VideoView>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -3,6 +3,7 @@ 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
|
||||
@@ -110,5 +111,10 @@ namespace TV_Player
|
||||
{
|
||||
overlayPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
VideoView.MediaPlayer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Windows.Input;
|
||||
using TV_Player.ViewModels;
|
||||
|
||||
namespace TV_Player
|
||||
{
|
||||
@@ -6,43 +8,32 @@ namespace TV_Player
|
||||
public class PlayerViewModel: ObservableViewModelBase
|
||||
{
|
||||
|
||||
private readonly M3UInfo _currentProgram;
|
||||
|
||||
private string _urlSource;
|
||||
public string URLSource
|
||||
private M3UInfo _currentProgram;
|
||||
public M3UInfo SelectedProgram
|
||||
{
|
||||
get => _urlSource;
|
||||
set => SetProperty(ref _urlSource, value);
|
||||
get => _currentProgram;
|
||||
set => SetProperty(ref _currentProgram, value);
|
||||
}
|
||||
|
||||
public GroupInfo SelectedItem { get; set; }
|
||||
public ICommand PlayCommand { get; }
|
||||
public M3UInfo SelectedItem { get; set; }
|
||||
public ICommand BackCommand { get; }
|
||||
|
||||
public PlayerViewModel(M3UInfo selectedProgram)
|
||||
{
|
||||
_currentProgram = selectedProgram;
|
||||
//PlayM3U8(_currentProgram.Url);
|
||||
//_libVLC = new LibVLC();
|
||||
//_mediaPlayer = new MediaPlayer(new Media(_libVLC, new Uri(_currentProgram.Url)));
|
||||
//_mediaPlayer.Play();
|
||||
//PlayCommand = new Command(OnPlayButtonClicked);
|
||||
BackCommand = new RelayCommand(OnButtonBackClick);
|
||||
|
||||
}
|
||||
|
||||
private void OnPlayButtonClicked()
|
||||
private void OnButtonBackClick()
|
||||
{
|
||||
PlayM3U8(_currentProgram.Url);
|
||||
var groupInfo = new GroupInfo() { Name = _currentProgram.GroupTitle, Count = 0 };
|
||||
|
||||
var programListViewModel = new ProgramsListViewModel(groupInfo);
|
||||
var conrtrol = new ProgramsList();
|
||||
TVPlayerViewModel.Instance.SetPageContext(conrtrol, programListViewModel);
|
||||
}
|
||||
|
||||
private void PlayM3U8(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
URLSource = _currentProgram.Url;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Handle exceptions
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,9 @@ namespace TV_Player
|
||||
|
||||
private void OnItemSelected()
|
||||
{
|
||||
//var navigation = (INavigation)Application.Current.MainPage.Navigation;
|
||||
|
||||
var programListViewModel = new ProgramsListViewModel(SelectedItem);
|
||||
var conrtrol = new ProgramsList();
|
||||
TVPlayerViewModel.Instance.SetPageContext(conrtrol, programListViewModel);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,22 +24,10 @@ namespace TV_Player
|
||||
|
||||
private void OnItemSelected()
|
||||
{
|
||||
|
||||
var playerViewModel = new PlayerViewModel(SelectedItem);
|
||||
var conrtrol = new VideoPlayer();
|
||||
conrtrol.SourceUrl = SelectedItem.Url;
|
||||
TVPlayerViewModel.Instance.SetPageContext(conrtrol, playerViewModel);
|
||||
//var navigation = (INavigation)Application.Current.MainPage.Navigation;
|
||||
|
||||
//var playerViewModel = new PlayerViewModel(SelectedItem);
|
||||
|
||||
//// Create a new SecondPage and set its BindingContext to the ViewModel
|
||||
//var playerPage = new PlayerPage
|
||||
//{
|
||||
// BindingContext = playerViewModel
|
||||
//};
|
||||
//// Navigate to the OtherPage
|
||||
//navigation.PushAsync(playerPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user