Beispiel #1
0
        private void ShowActualPlayingMessage(PlayStreamInfo playStreamInfo = null)
        {
            if (playStreamInfo == null ||
                playStreamInfo.Channel == null)
            {
                if (_viewModel.SelectedChannel == null)
                {
                    return;
                }

                playStreamInfo = new PlayStreamInfo
                {
                    Channel = _viewModel.SelectedChannel
                };

                var eitManager = _driver.GetEITManager(_viewModel.SelectedChannel.Frequency);
                if (eitManager != null)
                {
                    playStreamInfo.CurrentEvent = eitManager.GetEvent(DateTime.Now, Convert.ToInt32(_viewModel.SelectedChannel.ProgramMapPID));
                }
            }

            var msg = "\u25B6 " + playStreamInfo.Channel.Name;

            if (playStreamInfo.CurrentEvent != null)
            {
                msg += $" - {playStreamInfo.CurrentEvent.EventName}";
            }

            // showing signal percents only for the first time
            if (playStreamInfo.SignalStrengthPercentage > 0)
            {
                msg += $" (signal {playStreamInfo.SignalStrengthPercentage}%)";
                playStreamInfo.SignalStrengthPercentage = 0;
            }

            MessagingCenter.Send(msg, BaseViewModel.MSG_ToastMessage);
        }
Beispiel #2
0
        public async Task ActionPlay(DVBTChannel channel = null)
        {
            if (channel == null)
            {
                channel = _viewModel.SelectedChannel;
            }

            if (channel == null)
            {
                return;
            }

            if (PlayingState == PlayingStateEnum.Recording)
            {
                MessagingCenter.Send($"Playing {channel.Name} failed (recording in progress)", BaseViewModel.MSG_ToastMessage);
                return;
            }

            if (PlayingState == PlayingStateEnum.PlayingInPreview && _viewModel.PlayingChannel == channel)
            {
                PlayingState = PlayingStateEnum.Playing;
                return;
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                if (PlayingState == PlayingStateEnum.Playing || PlayingState == PlayingStateEnum.PlayingInPreview)
                {
                    videoView.MediaPlayer.Stop();
                }
            });

            if (!_driver.Started)
            {
                MessagingCenter.Send($"Playing {channel.Name} failed (device connection error)", BaseViewModel.MSG_ToastMessage);
                return;
            }

            var playRes = await _driver.Play(channel.Frequency, channel.Bandwdith, channel.DVBTType, channel.PIDsArary);

            if (!playRes.OK)
            {
                MessagingCenter.Send($"Playing {channel.Name} failed (device connection error)", BaseViewModel.MSG_ToastMessage);
                return;
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                if (_driver.VideoStream != null)
                {
                    _media = new Media(_libVLC, _driver.VideoStream, new string[] { });
                    videoView.MediaPlayer.Play(_media);
                }
            });

            var playInfo = new PlayStreamInfo
            {
                Channel = channel,
                SignalStrengthPercentage = playRes.SignalStrengthPercentage
            };

            var eitManager = _driver.GetEITManager(channel.Frequency);

            if (eitManager != null)
            {
                playInfo.CurrentEvent = eitManager.GetEvent(DateTime.Now, Convert.ToInt32(channel.ProgramMapPID));
            }

            ShowActualPlayingMessage(playInfo);

            if (_config.PlayOnBackground)
            {
                MessagingCenter.Send <MainPage, PlayStreamInfo>(this, BaseViewModel.MSG_PlayInBackgroundNotification, playInfo);
            }

            _viewModel.PlayingChannel = channel;
            PlayingState = PlayingStateEnum.Playing;
        }
Beispiel #3
0
        public async Task PlayChannel(DVBTChannel channel = null)
        {
            if (channel == null)
            {
                channel = SelectedChannel;
                if (channel == null)
                {
                    return;
                }
            }

            var playInfo = new PlayStreamInfo
            {
                Channel = channel
            };

            if (_recordingChannel != null)
            {
                MessagingCenter.Send($"Playing {channel.Name} failed (recording in progress)", BaseViewModel.MSG_ToastMessage);
                return;
            }

            _loggingService.Debug($"Playing channel {channel}");

            try
            {
                if (!_driver.Started)
                {
                    MessagingCenter.Send($"Playing {channel.Name} failed (device connection error)", BaseViewModel.MSG_ToastMessage);
                    return;
                }

                IsRefreshing = true;

                var playRes = await _driver.Play(channel.Frequency, channel.Bandwdith, channel.DVBTType, channel.PIDsArary);

                if (!playRes.OK)
                {
                    throw new Exception("Play returned false");
                }

                playInfo.SignalStrengthPercentage = playRes.SignalStrengthPercentage;

                var eitManager = _driver.GetEITManager(channel.Frequency);
                if (eitManager != null)
                {
                    playInfo.CurrentEvent = eitManager.GetEvent(DateTime.Now, Convert.ToInt32(channel.ProgramMapPID));
                }

                MessagingCenter.Send(playInfo, BaseViewModel.MSG_PlayStream);
            }
            catch (Exception ex)
            {
                _loggingService.Error(ex, $"Playing {channel.Name} failed");

                MessagingCenter.Send($"Playing {channel.Name} failed", BaseViewModel.MSG_ToastMessage);
            }
            finally
            {
                IsRefreshing = false;
            }
        }