示例#1
0
        private static void RefreshCurrentAndNext(Channel channel, bool forceUpdate)
        {
            TimeSpan ts = DateTime.Now - _programUpdateTimer;

            if (ts.TotalMilliseconds < 1000 && !forceUpdate)
            {
                return;
            }
            _programUpdateTimer = DateTime.Now;

            lock (_refreshCurrAndNextLock)
            {
                using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent())
                    using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                    {
                        CurrentAndNextProgram currentAndNext = tvSchedulerAgent.GetCurrentAndNextForChannel(channel.ChannelId, false, null);
                        if (currentAndNext != null)
                        {
                            if (currentAndNext.Current != null)
                            {
                                _currentProgram = tvGuideAgent.GetProgramById(currentAndNext.Current.GuideProgramId);
                            }
                            else
                            {
                                _currentProgram = null;
                            }
                            if (currentAndNext.Next != null)
                            {
                                _nextProgram = tvGuideAgent.GetProgramById(currentAndNext.Next.GuideProgramId);
                            }
                            else
                            {
                                _nextProgram = null;
                            }
                        }
                        else
                        {
                            _nextProgram    = null;
                            _currentProgram = null;
                        }
                    }
            }
        }
示例#2
0
        private static void RefreshCurrentAndNext(Channel channel, bool forceUpdate)
        {
            TimeSpan ts = DateTime.Now - _programUpdateTimer;

            if (ts.TotalMilliseconds < 1000 && !forceUpdate)
            {
                return;
            }
            _programUpdateTimer = DateTime.Now;

            lock (_refreshCurrAndNextLock)
            {
                CurrentAndNextProgram currentAndNext = Proxies.SchedulerService.GetCurrentAndNextForChannel(channel.ChannelId, false, null).Result;
                if (currentAndNext != null)
                {
                    if (currentAndNext.Current != null)
                    {
                        _currentProgram = Proxies.GuideService.GetProgramById(currentAndNext.Current.GuideProgramId).Result;
                    }
                    else
                    {
                        _currentProgram = null;
                    }
                    if (currentAndNext.Next != null)
                    {
                        _nextProgram = Proxies.GuideService.GetProgramById(currentAndNext.Next.GuideProgramId).Result;
                    }
                    else
                    {
                        _nextProgram = null;
                    }
                }
                else
                {
                    _nextProgram    = null;
                    _currentProgram = null;
                }
            }
        }
示例#3
0
 public CurrentAndNextProgramView(CurrentAndNextProgram currentAndNext)
 {
     _currentAndNext = currentAndNext;
 }
示例#4
0
        private void TuneLiveStream(Channel channel)
        {
            Log.Debug("ChannelNavigator: TuneLiveStream(), channel = {0}", channel.DisplayName);
            if (channel != null)
            {
                using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                {
                    LiveStream            liveStream     = _liveStream;
                    CurrentAndNextProgram currentAndNext = tvSchedulerAgent.GetCurrentAndNextForChannel(channel.ChannelId, true, _liveStream);//null);

                    _currentChannel     = channel;
                    _doingChannelChange = true;
                    RenderBlackImage();

                    if (liveStream != null)
                    {
                        try
                        {
                            g_Player.PauseGraph();
                            g_Player.OnZapping(0x80);

                            result = this.ControlAgent.TuneLiveStream(channel, ref liveStream);
                            Log.Debug("ChannelNavigator: First try to re-tune the existing TV stream (staying on the same card), result = {0}", result);

                            if (result == LiveStreamResult.Succeeded)
                            {
                                if (_isAnalog)
                                {
                                    g_Player.OnZapping(-1);
                                }

                                double duration = g_Player.Duration;
                                if (g_Player.Duration < 0.0)
                                {
                                    result = LiveStreamResult.UnknownError;
                                }
                                else
                                {
                                    g_Player.SeekAbsolute(duration);
                                    g_Player.ContinueGraph();
                                }
                            }
                            else if (result == LiveStreamResult.NoRetunePossible)// not mapped to card, card in use by recorder or other user ---> start new stream
                            {
                                // Now re-try the new channel with a new stream.
                                Log.Debug("ChannelNavigator: Seems a re-tune has failed, stop the current stream and start a new one");
                                SilentlyStopLiveStream(liveStream);
                                result = StartAndPlayNewLiveStream(channel, liveStream);
                            }
                        }
                        catch
                        {
                            result = LiveStreamResult.UnknownError;
                            Log.Error("ChannelNavigator: TuneLiveStream error");
                        }
                    }
                    else
                    {
                        result = StartAndPlayNewLiveStream(channel, liveStream);
                    }

                    _doingChannelChange = false;
                    if (result == LiveStreamResult.Succeeded)
                    {
                        _lastChannelChangeFailed = false;
                        StopRenderBlackImage();
                    }
                    else
                    {
                        _lastChannelChangeFailed = true;
                        SilentlyStopLiveStream(liveStream);
                        ChannelTuneFailedNotifyUser(result, channel);
                    }
                }
            }
        }