Example #1
0
        public TunePage(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config, ChannelService channelService)
        {
            InitializeComponent();

            _loggingService = loggingService;
            _dialogService  = dialogService;
            _driver         = driver;
            _config         = config;

            BindingContext           = _viewModel = new TunePageViewModel(_loggingService, _dialogService, _driver, _config, channelService);
            _viewModel.TuneFrequency = "730";

            ChannelsListView.ItemSelected += ChannelsListView_ItemSelected;

            Appearing += TunePage_Appearing;

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_UpdateDriverState, (message) =>
            {
                _viewModel.UpdateDriverState();
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_DVBTDriverConfigurationFailed, (message) =>
            {
                Device.BeginInvokeOnMainThread(delegate
                {
                    _viewModel.UpdateDriverState();
                });
            });
        }
        public PlayerPageViewModel(DVBTTelevizorConfiguration config)
            : base(config)
        {
            AnimeIconCommand = new Command(Anime);

            BackgroundCommandWorker.RunInBackground(AnimeIconCommand, 1, 1);
        }
Example #3
0
        public ServicePage(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config, PlayerPage playerPage)
        {
            InitializeComponent();

            _loggingService = loggingService;
            _dialogService  = dialogService;
            _driver         = driver;
            _config         = config;
            _playerPage     = playerPage;

            BindingContext           = _viewModel = new ServicePageViewModel(_loggingService, _dialogService, _driver, _config);
            _viewModel.TuneFrequency = "626";
            _viewModel.SelectedDeliverySystemType = _viewModel.DeliverySystemTypes[1];

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_UpdateDriverState, (message) =>
            {
                _viewModel.UpdateDriverState();
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_DVBTDriverConfigurationFailed, (message) =>
            {
                Device.BeginInvokeOnMainThread(delegate
                {
                    _viewModel.UpdateDriverState();
                });
            });
        }
Example #4
0
        private Dictionary <long, EITManager> _eitManagers = new Dictionary <long, EITManager>();  // frequency -> EITManager

        public DVBTDriverManager(ILoggingService loggingService, DVBTTelevizorConfiguration config)
        {
            _log = loggingService;

            _log.Debug($"Initializing DVBT driver manager");

            _config = config;
        }
Example #5
0
        public App(ILoggingService loggingService, DVBTTelevizorConfiguration config, IDVBTDriverManager driverManager)
        {
            InitializeComponent();

            _loggingService = loggingService;
            _config         = config;
            _driver         = driverManager;

            _mainPage = new MainPage(_loggingService, config, driverManager);
            MainPage  = new NavigationPage(_mainPage);
        }
Example #6
0
        public SettingsPageViewModel(ILoggingService loggingService, IDialogService dialogService, DVBTTelevizorConfiguration config, ChannelService channelService)
            : base(config)
        {
            _loggingService = loggingService;
            _dialogService  = dialogService;
            _channelService = channelService;

            _config = config;

            ClearChannelsCommand = new Command(async() => await ClearChannels());

            ExportChannelsCommand = new Command(async() => await Export());

            ImportChannelsCommand = new Command(async() => await Import());

            ShareChannelsCommand = new Command(async() => { await ShareLog(); });

            Donate1command  = new Command(async() => { await Donate("donation1"); });
            Donate5command  = new Command(async() => { await Donate("donation5"); });
            Donate10command = new Command(async() => { await Donate("donation10"); });
        }
Example #7
0
        public PlayerPage(IDVBTDriverManager driver, DVBTTelevizorConfiguration config)
        {
            InitializeComponent();

            BindingContext = _viewModel = new PlayerPageViewModel(config);

            _driver = driver;

            Appearing += PlayerPage_Appearing;

            Core.Initialize();

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC)
            {
                EnableHardwareDecoding = true
            };
            videoView.MediaPlayer = _mediaPlayer;

            CheckStreamCommand = new Command(async() => await CheckStream());

            BackgroundCommandWorker.RunInBackground(CheckStreamCommand, 3, 5);
        }
Example #8
0
        public MainPage(ILoggingService loggingService, DVBTTelevizorConfiguration config, IDVBTDriverManager driverManager)
        {
            InitializeComponent();

            _dlgService = new DialogService(this);

            _loggingService = loggingService;

            _config = config;

            _driver = driverManager;

            try
            {
                _playerPage = new PlayerPage(_driver, _config);
            } catch (Exception ex)
            {
                _loggingService.Error(ex, "Error while initializing player page");
            }

            _channelService = new ConfigChannelService(_loggingService, _config);

            _tunePage        = new TunePage(_loggingService, _dlgService, _driver, _config, _channelService);
            _servicePage     = new ServicePage(_loggingService, _dlgService, _driver, _config, _playerPage);
            _settingsPage    = new SettingsPage(_loggingService, _dlgService, _config, _channelService);
            _editChannelPage = new ChannelPage(_loggingService, _dlgService, _driver, _config);

            Core.Initialize();

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC)
            {
                EnableHardwareDecoding = true
            };
            videoView.MediaPlayer = _mediaPlayer;

            BindingContext = _viewModel = new MainPageViewModel(_loggingService, _dlgService, _driver, _config, _channelService);

            if (_config.AutoInitAfterStart)
            {
                Task.Run(() =>
                {
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(
                        new Action(
                            delegate
                    {
                        MessagingCenter.Send("", BaseViewModel.MSG_Init);
                    }));
                });
            }

            CheckStreamCommand = new Command(async() => await CheckStream());
            BackgroundCommandWorker.RunInBackground(CheckStreamCommand, 3, 5);

            _servicePage.Disappearing     += anyPage_Disappearing;
            _servicePage.Disappearing     += anyPage_Disappearing;
            _tunePage.Disappearing        += anyPage_Disappearing;
            _settingsPage.Disappearing    += anyPage_Disappearing;
            _editChannelPage.Disappearing += _editChannelPage_Disappearing;
            ChannelsListView.ItemSelected += ChannelsListView_ItemSelected;

            Appearing += MainPage_Appearing;

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_KeyDown, (key) =>
            {
                OnKeyDown(key);
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_EditChannel, (message) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(
                    delegate
                {
                    EditSelectedChannel();
                });
            });

            MessagingCenter.Subscribe <PlayStreamInfo> (this, BaseViewModel.MSG_PlayStream, (playStreamInfo) =>
            {
                Task.Run(async() =>
                {
                    await ActionPlay();
                });
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_DVBTDriverConfiguration, (message) =>
            {
                _loggingService.Debug($"Received DVBTDriverConfiguration message: {message}");

                if (!_driver.Started)
                {
                    _viewModel.ConnectDriver(message);
                }
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_UpdateDriverState, (message) =>
            {
                _viewModel.UpdateDriverState();
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_DVBTDriverConfigurationFailed, (message) =>
            {
                Device.BeginInvokeOnMainThread(delegate
                {
                    _viewModel.UpdateDriverState();

                    MessagingCenter.Send($"Device connection error ({message})", BaseViewModel.MSG_ToastMessage);
                });
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_PlayPreviousChannel, (msg) =>
            {
                OnKeyUp();
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_PlayNextChannel, (msg) =>
            {
                OnKeyDown();
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_StopStream, (msg) =>
            {
                StopPlayback();
            });

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_ImportChannelsList, (message) =>
            {
                _viewModel.ImportCommand.Execute(message);
            });
        }
 public ConfigChannelService(ILoggingService logingService, DVBTTelevizorConfiguration config) : base(logingService, config)
 {
 }
Example #10
0
        public ChannelPage(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config)
        {
            InitializeComponent();

            _loggingService = loggingService;
            _dialogService  = dialogService;

            BindingContext = _viewModel = new ChannelPageViewModel(_loggingService, _dialogService, driver, config);

            Appearing += ChannelPage_Appearing;
        }
Example #11
0
        public BaseViewModel(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config)
            : base(config)
        {
            _loggingService = loggingService;
            _dialogService  = dialogService;
            _driver         = driver;

            new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;

                do
                {
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(
                        new Action(
                            delegate
                    {
                        OnPropertyChanged(nameof(DataStreamInfo));
                    }));

                    // 2 secs delay
                    Thread.Sleep(2 * 1000);
                } while (true);
            }).Start();
        }
Example #12
0
 public ConfigViewModel(DVBTTelevizorConfiguration config)
 {
     _config = config;
 }
Example #13
0
        public ServicePageViewModel(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config)
            : base(loggingService, dialogService, driver, config)
        {
            FillDeliverySystemTypes();

            GetVersionCommand      = new Command(async() => await GetVersion());
            GetStatusCommand       = new Command(async() => await GetStatus());
            GetCapabilitiesCommand = new Command(async() => await GetCapabilities());
            TuneCommand            = new Command(async() => await Tune());

            SetPIDsCommand = new Command(async() => await SetPIDs());

            PlayCommand = new Command(async() => await Play());

            ScanPSICommand = new Command(async() => await ScanPSI());
            ScanEITCommand = new Command(async() => await ScanEIT());

            StartRecordCommand = new Command(async() => await StartRecord());
            StopRecordCommand  = new Command(async() => await StopRecord());
        }
 public ChannelPageViewModel(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config)
     : base(loggingService, dialogService, driver, config)
 {
     _loggingService = loggingService;
     _dialogService  = dialogService;
 }
Example #15
0
 public TuneViewModel(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config)
     : base(loggingService, dialogService, driver, config)
 {
     FillFrequencyChannels();
 }
Example #16
0
        public TunePageViewModel(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config, ChannelService channelService)
            : base(loggingService, dialogService, driver, config)
        {
            _channelService = channelService;

            TuneCommand        = new Command(async() => await Tune());
            AbortTuneCommand   = new Command(async() => await AbortTune());
            FinishTunedCommand = new Command(async() => await FinishTune());
        }
Example #17
0
        public MainPageViewModel(ILoggingService loggingService, IDialogService dialogService, IDVBTDriverManager driver, DVBTTelevizorConfiguration config, ChannelService channelService)
            : base(loggingService, dialogService, driver, config)
        {
            _channelService = channelService;

            RefreshCommand        = new Command(async() => await Refresh());
            RefreshEPGCommand     = new Command(async() => await RefreshEPG());
            LongPressCommand      = new Command(async(itm) => await LongPress(itm));
            VideoLongPressCommand = new Command(async(itm) => await VideoLongPress());
            ShortPressCommand     = new Command(ShortPress);
            ImportCommand         = new Command(async(json) => await ImportList(json));

            UpCommand    = new Command(async(key) => await AnyKeyPressed("up"));
            DownCommand  = new Command(async(key) => await AnyKeyPressed("down"));
            LeftCommand  = new Command(async(key) => await AnyKeyPressed("left"));
            RightCommand = new Command(async(key) => await AnyKeyPressed("right"));

            OKCommand   = new Command(async() => await AnyKeyPressed("enter"));
            BackCommand = new Command(async() => await AnyKeyPressed("escape"));

            AnimeIconCommand = new Command(async() => await Anime());

            BackgroundCommandWorker.RunInBackground(RefreshEPGCommand, 2, 10);
            BackgroundCommandWorker.RunInBackground(AnimeIconCommand, 1, 1);
        }
Example #18
0
 public ChannelService(ILoggingService logingService, DVBTTelevizorConfiguration config)
 {
     _log    = logingService;
     _config = config;
 }
Example #19
0
        public SettingsPage(ILoggingService loggingService, IDialogService dialogService, DVBTTelevizorConfiguration config, ChannelService channelService)
        {
            InitializeComponent();

            _loggingService = loggingService;
            _dialogService  = dialogService;

            BindingContext = _viewModel = new SettingsPageViewModel(_loggingService, _dialogService, config, channelService);

            PlayOnBackgroundSwitch.Toggled += PlayOnBackgroundSwitch_Toggled;

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_RequestBatterySettings, async(sender) =>
            {
                if (await _dialogService.Confirm("You should manually turn battery optimization off for DVBT Televizor. Open settings?"))
                {
                    MessagingCenter.Send <SettingsPage>(this, BaseViewModel.MSG_SetBatterySettings);
                }
            });
        }