Got WPF version work

This commit is contained in:
Vova
2024-01-18 17:42:44 +02:00
parent df51ee3ad6
commit 10b4146772
64 changed files with 866 additions and 411 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
namespace TV_Player
namespace TV_Player.MAUI
{
public class GroupInfo
{
public string Name { get; set; }
public int Count { get; set; }
+1 -1
View File
@@ -1,4 +1,4 @@
namespace TV_Player
namespace TV_Player.MAUI
{
public class M3UInfo
{
+2 -2
View File
@@ -1,7 +1,7 @@
using System.Net.Http.Headers;
using System.Text.RegularExpressions;
namespace TV_Player
namespace TV_Player.MAUI
{
public static class M3UParser
{
@@ -89,7 +89,7 @@ namespace TV_Player
GroupTitle = match.Groups["GroupTitle"].Value,
Logo = match.Groups["Logo"].Value,
Name = match.Groups["Name"].Value,
Url = match.Groups["Url"].Value
Url = match.Groups["URL"].Value
};
return true;
}
+12 -2
View File
@@ -1,6 +1,6 @@
using System.Windows.Input;
namespace TV_Player
namespace TV_Player.MAUI
{
public class MainViewModel : ObservableViewModelBase
{
@@ -22,7 +22,17 @@ namespace TV_Player
private void OnItemSelected()
{
var navigation = (INavigation)Application.Current.MainPage.Navigation;
var programPageViewModel = new ProgramViewModel(SelectedItem);
// Create a new SecondPage and set its BindingContext to the ViewModel
var programPage = new ProgramPage
{
BindingContext = programPageViewModel
};
// Navigate to the OtherPage
navigation.PushAsync(programPage);
}
}
}
@@ -1,7 +1,7 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace TV_Player
namespace TV_Player.MAUI
{
public abstract class ObservableViewModelBase : INotifyPropertyChanged
{
+49
View File
@@ -0,0 +1,49 @@
using LibVLCSharp.Shared;
using System.Windows.Input;
namespace TV_Player.MAUI
{
public class PlayerViewModel: ObservableViewModelBase
{
private readonly M3UInfo _currentProgram;
private string _urlSource;
public string URLSource
{
get => _urlSource;
set => SetProperty(ref _urlSource, value);
}
public GroupInfo SelectedItem { get; set; }
public ICommand PlayCommand { 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);
}
private void OnPlayButtonClicked()
{
PlayM3U8(_currentProgram.Url);
}
private void PlayM3U8(string url)
{
try
{
URLSource = _currentProgram.Url;
}
catch (Exception ex)
{
// Handle exceptions
}
}
}
}
+38
View File
@@ -0,0 +1,38 @@
using System.Windows.Input;
namespace TV_Player.MAUI
{
public class ProgramViewModel : ObservableViewModelBase
{
private List<M3UInfo> _programs;
public List<M3UInfo> Programs
{
get => _programs;
set => SetProperty(ref _programs, value);
}
public M3UInfo SelectedItem { get; set; }
public ICommand ItemSelectedCommand { get; }
public ProgramViewModel(GroupInfo groupInfo)
{
ItemSelectedCommand = new Command(OnItemSelected);
ProgramsData.Instance.AllPrograms.Subscribe(x=>Programs = x.Where(p=>p.GroupTitle== groupInfo.Name).ToList());
}
private void OnItemSelected()
{
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);
}
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
using System.Reactive.Subjects;
namespace TV_Player
namespace TV_Player.MAUI
{
public class ProgramsData
{
@@ -14,10 +14,10 @@ namespace TV_Player
}
}
private readonly Subject<List<M3UInfo>> programsSubject = new Subject<List<M3UInfo>>();
private readonly Subject<List<GroupInfo>> groupsSubject = new Subject<List<GroupInfo>>();
private readonly ReplaySubject<List<M3UInfo>> programsSubject = new ReplaySubject<List<M3UInfo>>();
private readonly ReplaySubject<List<GroupInfo>> groupsSubject = new ReplaySubject<List<GroupInfo>>();
public IObservable<List<M3UInfo>> AllPrograms => programsSubject;
public Subject<List<GroupInfo>> GroupsInformation => groupsSubject;
public IObservable<List<GroupInfo>> GroupsInformation => groupsSubject;
private ProgramsData()
{