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());
        }
Beispiel #2
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"); });
        }
Beispiel #3
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 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);
                }
            });
        }
Beispiel #5
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);
        }
Beispiel #6
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();
                });
            });
        }