示例#1
0
        internal void OnPlaybackResumed()
        {
            if (this.PlaybackResumed == null)
            {
                return;
            }

            XbmcMediaPlayer player = this.getActivePlayer();

            if (player == null)
            {
                return;
            }

            TimeSpan current = new TimeSpan();
            TimeSpan total   = new TimeSpan();

            if (player is XbmcVideoPlayer)
            {
                ((XbmcVideoPlayer)player).GetTime(out current, out total);
            }
            else if (player is XbmcAudioPlayer)
            {
                ((XbmcAudioPlayer)player).GetTime(out current, out total);
            }

            this.PlaybackResumed(this, new XbmcPlayerPlaybackPositionChangedEventArgs(player, current, total));
        }
示例#2
0
        internal XbmcPlayerPlaybackChangedEventArgs(XbmcMediaPlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException();
            }

            this.player = player;
        }
        internal XbmcPlayerPlaybackChangedEventArgs(XbmcMediaPlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException();
            }

            this.player = player;
        }
        internal XbmcPlayerPlaybackPositionChangedEventArgs(XbmcMediaPlayer player, TimeSpan position, TimeSpan length)
            : base(player)
        {
            if (position == null)
            {
                throw new ArgumentNullException("position");
            }
            if (length == null)
            {
                throw new ArgumentNullException("length");
            }

            this.position = position;
            this.length   = length;
        }
示例#5
0
        internal void OnPlaybackStarted()
        {
            if (this.PlaybackStarted == null)
            {
                return;
            }

            XbmcMediaPlayer player = this.getActivePlayer();

            if (player == null)
            {
                return;
            }

            this.PlaybackStarted(this, new XbmcPlayerPlaybackChangedEventArgs(player));
        }
示例#6
0
        internal void OnPlaybackSeekChapter()
        {
            if (this.PlaybackSeekChapter == null)
            {
                return;
            }

            TimeSpan        current, total;
            XbmcMediaPlayer player = this.getProgress(out current, out total);

            if (player == null)
            {
                return;
            }

            this.PlaybackSeekChapter(this, new XbmcPlayerPlaybackPositionChangedEventArgs(player, current, total));
        }
示例#7
0
        internal void OnPlaybackSpeedChanged()
        {
            if (this.PlaybackSpeedChanged == null)
            {
                return;
            }

            TimeSpan        current, total;
            XbmcMediaPlayer player = this.getProgress(out current, out total);

            current = TimeSpan.Parse(this.getInfo <string>("Player.SeekTime"));
            if (player == null)
            {
                return;
            }

            this.PlaybackSpeedChanged(this, new XbmcPlayerPlaybackSpeedChangedEventArgs(player, current, total, player.Speed));
        }
示例#8
0
        private XbmcMediaPlayer getProgress(out TimeSpan current, out TimeSpan total)
        {
            current = new TimeSpan();
            total   = new TimeSpan();

            XbmcMediaPlayer player = this.getActivePlayer();

            if (player == null)
            {
                return(null);
            }

            if (player is XbmcVideoPlayer)
            {
                ((XbmcVideoPlayer)player).GetTime(out current, out total);
            }
            else if (player is XbmcAudioPlayer)
            {
                ((XbmcAudioPlayer)player).GetTime(out current, out total);
            }

            return(player);
        }
示例#9
0
        private void playbackStopped()
        {
            this.playerState = PlayerState.Stopped;
            this.player = null;
            this.currentlyPlaying = null;

            this.progressTimer.Stop();
            this.position = new TimeSpan();
            this.length = new TimeSpan();

            this.Update();
        }
示例#10
0
        private void xbmcPlaybackStarted(object sender, XbmcPlayerPlaybackChangedEventArgs e)
        {
            if (e == null || e.Player == null)
            {
                return;
            }

            Logging.Log(LoggingArea, "Playback started");

            if (Settings.Default.XbmcOnPlayText.CompareTo("") != 0)
            {
                this.display.SetText(Settings.Default.XbmcOnPlayText, Settings.Default.XbmcOnEventTextDelayMS);
            }

            this.player = e.Player;
            this.playerState = PlayerState.Playing;

            this.getTime(out this.position, out this.length);
            Logging.Log(LoggingArea, "Position " + this.position.TotalSeconds + " of " + this.length.TotalSeconds + " [s]");
            this.progressTimer.Start();

            this.update();
        }
示例#11
0
        private void xbmcConnected(object sender, EventArgs e)
        {
            lock (connectionLocking)
            {
                this.connected = true;

                bool audio, video, pictures;
                int id;
                this.xbmc.Player.GetActivePlayers(out video, out audio, out pictures, out id);

                if (video)
                {
                    this.player = this.xbmc.Player.Video;
                }
                else if (audio)
                {
                    this.player = this.xbmc.Player.Audio;
                }
                else if (pictures)
                {
                    this.player = this.xbmc.Player.Pictures;
                }
            }

            try
            {
                this.semReady.Release();
            }
            catch (SemaphoreFullException)
            {
                Logging.Error(LoggingArea, "Error: 'SemaphoreFullException' for semReady in XbmcHandler.xbmcConnected()");
            }

            if (this.player != null)
            {
                this.getTime(out this.position, out this.length);
                this.progressTimer.Start();
            }

            try
            {
                IDictionary<string, string> time = this.xbmc.System.GetInfoLabels("System.Time(hh)",
                                                                                  "System.Time(mm)",
                                                                                  "System.Time(ss)");
                this.systemTime = DateTime.Now;
                //this.systemTime -= this.systemTime.TimeOfDay;
                //this.systemTime +=
                //    TimeSpan.Parse(time["System.Time(hh)"] + ":" + time["System.Time(mm)"] + ":" +
                //                   time["System.Time(ss)"]);
                this.validSystemTime = true;

                this.systemTimeTimer.Start();
            }
            catch (Exception ex)
            {
                this.validSystemTime = false;
                Logging.Error("XBMC", "Could not get current time", ex);
            }

            if (Settings.Default.XbmcOnConnectedText.CompareTo("") != 0)
            {
                this.display.SetText(Settings.Default.XbmcOnConnectedText, Settings.Default.XbmcOnEventTextDelayMS);
                this.displayIdle();
            }

            this.update();
        }
 internal XbmcPlayerPlaybackSpeedChangedEventArgs(XbmcMediaPlayer player, TimeSpan position, TimeSpan length, int speed)
     : base(player, position, length)
 {
     this.speed = speed;
 }
示例#13
0
        private void xbmcPlaybackStarted(object sender, XbmcPlayerPlaybackChangedEventArgs e)
        {
            if (e == null || e.Player == null)
            {
                return;
            }

            Logging.Log("XBMC Handler", "Playback started");

            this.player = e.Player;

            this.getTime(out this.position, out this.length);
            this.progressTimer.Start();

            this.update();
        }
示例#14
0
        private void xbmcConnected(object sender, EventArgs e)
        {
            this.connected = true;

            bool audio, video, pictures;
            this.xbmc.Player.GetActivePlayers(out video, out audio, out pictures);

            if (video)
            {
                this.player = this.xbmc.Player.Video;
            }
            else if (audio)
            {
                this.player = this.xbmc.Player.Audio;
            }
            else if (pictures)
            {
                this.player = this.xbmc.Player.Pictures;
            }

            this.semReady.Release();

            if (this.player != null)
            {
                this.getTime(out this.position, out this.length);
                this.progressTimer.Start();
            }

            this.update();
        }