예제 #1
0
 private void RaiseEventChanged (PlayerEventArgs args)
 {
     PlayerEventHandler handler = EventChanged;
     if (handler != null) {
         handler (args);
     }
 }
예제 #2
0
 protected virtual void OnEventChanged(PlayerEventArgs args)
 {
     if (ThreadAssist.InMainThread)
     {
         RaiseEventChanged(args);
     }
     else
     {
         ThreadAssist.ProxyToMain(delegate {
             RaiseEventChanged(args);
         });
     }
 }
예제 #3
0
        protected virtual void OnEventChanged(PlayerEventArgs args)
        {
            if (args.Event == PlayerEvent.StartOfStream && pending_track != null)
            {
                Log.DebugFormat("OnEventChanged called with StartOfStream.  Replacing current_track with pending_track: \"{0}\"",
                                pending_track.DisplayTrackTitle);
                CurrentTrackTimeStamp = DateTime.Now;
                current_track         = pending_track;
                pending_track         = null;
            }

            ThreadAssist.ProxyToMain(() => RaiseEventChanged(args));
        }
 public void ProcessEvent(PlayerEventArgs args, TrackInfo track, uint pos, uint len)
 {
     switch(args.Event) {
     case PlayerEvent.StateChange:
         StateChange((PlayerEventStateChangeArgs)args, track, pos, len);
         break;
     case PlayerEvent.TrackInfoUpdated:
         UpdateTrack(track, pos, len);
         break;
     case PlayerEvent.Iterate:
         UpdatePosition(pos, len);
         break;
     }
 }
예제 #5
0
        protected virtual void OnEventChanged (PlayerEventArgs args)
        {
            if (args.Event == PlayerEvent.StartOfStream && pending_track != null) {
                Log.DebugFormat ("OnEventChanged called with StartOfStream.  Replacing current_track with pending_track: \"{0}\"",
                                 pending_track.DisplayTrackTitle);
                current_track = pending_track;
                pending_track = null;
            }

            if (ThreadAssist.InMainThread) {
                RaiseEventChanged (args);
            } else {
                ThreadAssist.ProxyToMain (delegate {
                    RaiseEventChanged (args);
                });
            }
        }
예제 #6
0
        private void OnEngineEventChanged(PlayerEventArgs args)
        {
            if (CurrentTrack != null)
            {
                if (args.Event == PlayerEvent.Error &&
                    CurrentTrack.PlaybackError == StreamPlaybackError.None)
                {
                    CurrentTrack.SavePlaybackError(StreamPlaybackError.Unknown);
                }
                else if (args.Event == PlayerEvent.Iterate &&
                         CurrentTrack.PlaybackError != StreamPlaybackError.None)
                {
                    CurrentTrack.SavePlaybackError(StreamPlaybackError.None);
                }
            }

            if (args.Event == PlayerEvent.StartOfStream)
            {
                incremented_last_played = false;
            }
            else if (args.Event == PlayerEvent.EndOfStream)
            {
                IncrementLastPlayed();
            }

            RaiseEvent(args);

            // Do not raise iterate across DBus to avoid so many calls;
            // DBus clients should do their own iterating and
            // event/state checking locally
            if (args.Event == PlayerEvent.Iterate)
            {
                return;
            }

            DBusPlayerEventHandler dbus_handler = dbus_event_changed;

            if (dbus_handler != null)
            {
                dbus_handler(args.Event.ToString().ToLower(),
                             args is PlayerEventErrorArgs ? ((PlayerEventErrorArgs)args).Message : String.Empty,
                             args is PlayerEventBufferingArgs ? ((PlayerEventBufferingArgs)args).Progress : 0
                             );
            }
        }
예제 #7
0
 private void OnPlayerEvent (PlayerEventArgs args)
 {
     switch (args.Event) {
         case PlayerEvent.StartOfStream:
         case PlayerEvent.TrackInfoUpdated:
             player.AddPropertyChange (PlayerProperties.Metadata);
             break;
         case PlayerEvent.StateChange:
             player.AddPropertyChange (PlayerProperties.PlaybackStatus);
             break;
         case PlayerEvent.Seek:
             player.HandleSeek ();
             break;
         case PlayerEvent.Volume:
             player.AddPropertyChange (PlayerProperties.Volume);
             break;
     }
 }
예제 #8
0
        private void RaiseEvent(PlayerEventArgs args)
        {
            lock (event_handlers) {
                if (args.Event == PlayerEvent.StateChange && args is PlayerEventStateChangeArgs)
                {
                    HandleStateChange((PlayerEventStateChangeArgs)args);
                }

                LinkedListNode <PlayerEventHandlerSlot> node = event_handlers.First;
                while (node != null)
                {
                    if ((node.Value.EventMask & args.Event) == args.Event)
                    {
                        node.Value.Handler(args);
                    }
                    node = node.Next;
                }
            }
        }
        /// <summary>
        /// Callback for when player events occur
        /// </summary>
        /// <param name='args'>Event arguments</param>
        public void OnPlayerEvent(PlayerEventArgs args)
        {
            // Check what type of event it was - We need to know if playback
            // was stopped or started.
            switch (args.Event)
            {
                case PlayerEvent.StartOfStream:
                case PlayerEvent.TrackInfoUpdated:
                    UpdateStatus();
                    break;

                case PlayerEvent.EndOfStream:
                    OnStop();
                    break;

                case PlayerEvent.StateChange:
                    OnPlayerStateChange((PlayerEventStateChangeArgs)args);
                    break;
            }
        }
예제 #10
0
        private void RaiseEvent(PlayerEventArgs args)
        {
            lock (event_handlers) {
                if (args.Event == PlayerEvent.StateChange && args is PlayerEventStateChangeArgs)
                {
                    HandleStateChange((PlayerEventStateChangeArgs)args);
                }

                LinkedListNode <PlayerEventHandlerSlot> node = event_handlers.First;
                while (node != null)
                {
                    if ((node.Value.EventMask & args.Event) == args.Event)
                    {
                        try {
                            node.Value.Handler(args);
                        } catch (Exception e) {
                            Log.Exception(String.Format("Error running PlayerEngine handler for {0}", args.Event), e);
                        }
                    }
                    node = node.Next;
                }
            }
        }
예제 #11
0
        private void OnPlayerEvent(PlayerEventArgs args)
        {
            book_track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
            if (book_track == null || book_track.PrimarySourceId != this.DbId) {
                book_track = null;
            }

            switch (args.Event) {
                case PlayerEvent.StartOfStream:
                    if (book_track != null) {
                        StartTimeout ();

                        if (PlaybackSource.Book == null || PlaybackSource.Book.DbId != book_track.AlbumId) {
                            PlaybackSource.Book = DatabaseAlbumInfo.Provider.FetchSingle (book_track.AlbumId);
                        }

                        if (book_track.CacheModelId != PlaybackSource.DatabaseTrackModel.CacheId) {
                            var index = PlaybackSource.DatabaseTrackModel.IndexOfFirst (book_track);
                            if (index >= 0) {
                                ServiceManager.PlaybackController.PriorTrack = PlaybackSource.TrackModel [index];
                            } else {
                                Log.Error ("Audiobook track started, but couldn't find in the Audiobook.PlaybackSource");
                            }
                        }
                    }
                    break;
                case PlayerEvent.EndOfStream:
                    StopTimeout ();
                    break;
                case PlayerEvent.Seek:
                    UpdateLastPlayed ();
                    break;
            }
        }
예제 #12
0
        private void RaiseEvent(PlayerEventArgs args)
        {
            lock (event_handlers) {
                if (args.Event == PlayerEvent.StateChange && args is PlayerEventStateChangeArgs) {
                    HandleStateChange ((PlayerEventStateChangeArgs)args);
                }

                LinkedListNode<PlayerEventHandlerSlot> node = event_handlers.First;
                while (node != null) {
                    if ((node.Value.EventMask & args.Event) == args.Event) {
                        try {
                            node.Value.Handler (args);
                        } catch (Exception e) {
                            Log.Exception (String.Format ("Error running PlayerEngine handler for {0}", args.Event), e);
                        }
                    }
                    node = node.Next;
                }
            }
        }
예제 #13
0
        private void OnEngineEventChanged(PlayerEventArgs args)
        {
            if (CurrentTrack != null) {
                if (args.Event == PlayerEvent.Error
                    && CurrentTrack.PlaybackError == StreamPlaybackError.None) {
                    CurrentTrack.SavePlaybackError (StreamPlaybackError.Unknown);
                } else if (args.Event == PlayerEvent.Iterate
                    && CurrentTrack.PlaybackError != StreamPlaybackError.None) {
                    CurrentTrack.SavePlaybackError (StreamPlaybackError.None);
                }
            }

            if (args.Event == PlayerEvent.StartOfStream) {
                incremented_last_played = false;
            } else if (args.Event == PlayerEvent.EndOfStream) {
                IncrementLastPlayed ();
            }

            RaiseEvent (args);

            // Do not raise iterate across DBus to avoid so many calls;
            // DBus clients should do their own iterating and
            // event/state checking locally
            if (args.Event == PlayerEvent.Iterate) {
                return;
            }

            DBusPlayerEventHandler dbus_handler = dbus_event_changed;
            if (dbus_handler != null) {
                dbus_handler (args.Event.ToString ().ToLower (),
                    args is PlayerEventErrorArgs ? ((PlayerEventErrorArgs)args).Message : String.Empty,
                    args is PlayerEventBufferingArgs ? ((PlayerEventBufferingArgs)args).Progress : 0
                );
            }
        }
예제 #14
0
        private void OnPlayerEvent (PlayerEventArgs args)
        {
            if (args.Event == PlayerEvent.EndOfStream) {
                // If EoS is for the last track in the play queue
                if (this == ServiceManager.PlaybackController.Source &&
                    TrackModel.IndexOf (current_track) == Count - 1) {
                    SetCurrentTrack (null);
                    UpdatePlayQueue ();
                    if (was_playing) {
                        ServiceManager.PlaybackController.PriorTrack = prior_playback_track;
                    } else {
                        // Stop playback; nothing was playing before the play queue, so it doesn't
                        // make sense to continue playback.
                        ServiceManager.PlaybackController.StopWhenFinished = true;
                    }
                }

                if (ServiceManager.PlaybackController.StopWhenFinished) {
                    if (current_track != null && this == ServiceManager.PlaybackController.Source) {
                        int index = TrackModel.IndexOf (current_track) + 1;
                        SetCurrentTrack (index < Count ? TrackModel[index] as DatabaseTrackInfo : null);
                    }
                }
            } else if (args.Event == PlayerEvent.StartOfStream) {
                if (TrackModel.IndexOf (ServiceManager.PlayerEngine.CurrentTrack) != -1) {
                    SetCurrentTrack (ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo);
                    SetAsPlaybackSourceUnlessPlaying ();
                    UpdatePlayQueue ();
                } else {
                    prior_playback_track = ServiceManager.PlayerEngine.CurrentTrack;
                }
            }
        }
예제 #15
0
        private void OnPlayerEvent (PlayerEventArgs args)
        {
            switch (args.Event) {
                case PlayerEvent.StartOfStream:
                    // Queue the previous track in case of a skip
                    Queue (last_track);

                    st.Reset ();
                    song_start_time = DateTime.Now;
                    last_track = ServiceManager.PlayerEngine.CurrentTrack;
                    queued = false;
                    now_playing_sent = false;
                    iterate_countdown = 4 * 4;  /* we get roughly 4 events/sec */

                    break;

                case PlayerEvent.Seek:
                    st.SkipPosition ();
                    break;

                case PlayerEvent.Iterate:
                    // Queue as now playing
                    if (!now_playing_sent && iterate_countdown == 0) {
                        if (last_track != null && last_track.Duration.TotalSeconds > 30 &&
                            (actions["AudioscrobblerEnableAction"] as ToggleAction).Active &&
                            (last_track.MediaAttributes & TrackMediaAttributes.Music) != 0) {

                            connection.NowPlaying (last_track.ArtistName, last_track.TrackTitle,
                                last_track.AlbumTitle, last_track.Duration.TotalSeconds, last_track.TrackNumber);
                        }

                        now_playing_sent = true;
                    } else if (iterate_countdown > 0) {
                        iterate_countdown --;
                    }

                    st.IncreasePosition ();
                    break;

                case PlayerEvent.EndOfStream:
                    Queue (last_track);
                    last_track = null;
                    iterate_countdown = 4 * 4;
                    break;
            }
        }
예제 #16
0
 private void OnTrackInfoUpdated(PlayerEventArgs args)
 {
     CheckForSwitch ();
 }
예제 #17
0
        private void OnPlayerEvent (PlayerEventArgs args)
        {
            switch (args.Event) {
                case PlayerEvent.StartOfStream:
                    CurrentTrack = player_engine.CurrentTrack;
                    consecutive_errors = 0;
                    break;
                case PlayerEvent.EndOfStream:
                    EosTransition ();
                    break;
                case PlayerEvent.Error:
                    if (++consecutive_errors >= 5) {
                        consecutive_errors = 0;
                        player_engine.Close (false);
                        OnStopped ();
                        break;
                    }

                    CancelErrorTransition ();
                    // TODO why is this so long? any reason not to be instantaneous?
                    error_transition_id = Application.RunTimeout (250, delegate {
                        EosTransition ();
                        RequestTrackHandler ();
                        return true;
                    });
                    break;
                case PlayerEvent.StateChange:
                    if (((PlayerEventStateChangeArgs)args).Current != PlayerState.Loading) {
                        break;
                    }

                    TrackInfo track = player_engine.CurrentTrack;
                    if (changing_to_track != track && track != null) {
                        CurrentTrack = track;
                    }

                    changing_to_track = null;

                    if (!raise_started_after_transition) {
                        transition_track_started = false;
                        OnTrackStarted ();
                    } else {
                        transition_track_started = true;
                    }
                    break;
                case PlayerEvent.RequestNextTrack:
                    RequestTrackHandler ();
                    break;
            }
        }
예제 #18
0
        private void OnPlayerEvent(PlayerEventArgs args)
        {
            switch (args.Event) {
                case PlayerEvent.StartOfStream:
                case PlayerEvent.TrackInfoUpdated:
                    current_track = ServiceManager.PlayerEngine.CurrentTrack;
                    ToggleRatingMenuSensitive ();
                    ShowTrackNotification ();
                    break;
                case PlayerEvent.StateChange:
                    UpdateActions ();
                    break;
                case PlayerEvent.EndOfStream:
                    current_track = null;
                    ToggleRatingMenuSensitive ();
                    break;
            }

            if (notif_area != null) {
                notif_area.OnPlayerEvent (args);
            }
        }
        private void OnPlayerEvent(PlayerEventArgs args)
        {
            parser.ProcessEvent(args,
                ServiceManager.PlayerEngine.CurrentTrack,
                ServiceManager.PlayerEngine.Position,
                ServiceManager.PlayerEngine.Length);

            if (args.Event == PlayerEvent.StateChange)
            {
                switch(((PlayerEventStateChangeArgs)args).Current)
                {
                case PlayerState.NotReady:
                case PlayerState.Ready:
                case PlayerState.Idle:
                case PlayerState.Contacting:
                case PlayerState.Loading:
                case PlayerState.Loaded:
                    idlescreen.prio = LCDScreen.Prio.Foreground;
                    lcdclient.UpdScreen(idlescreen);
                    foreach(LCDScreen screen in userscreens.Keys)
                    {
                        screen.prio = LCDScreen.Prio.Hidden;
                        lcdclient.UpdScreen(screen);
                    }
                    break;
                case PlayerState.Playing:
                case PlayerState.Paused:
                    idlescreen.prio = LCDScreen.Prio.Hidden;
                    lcdclient.UpdScreen(idlescreen);
                    foreach(LCDScreen screen in userscreens.Keys)
                    {
                        screen.prio = LCDScreen.Prio.Foreground;
                        lcdclient.UpdScreen(screen);
                    }
                    break;
                }
            }
            lcdclient.UpdWidgetsAll(parser);
        }
 private void OnPlayerEvent(PlayerEventArgs args)
 {
     if (ContactContainerSource.ShareCurrentlyPlayingSchema.Get ()) {
         switch (args.Event) {
             case PlayerEvent.StartOfStream:
                 //AnnounceTrack (ServiceManager.PlayerEngine.CurrentTrack);
                 break;
             case PlayerEvent.StateChange:
                 PlayerEventStateChangeArgs state = args as PlayerEventStateChangeArgs;
                 if (state != null) {
                     switch (state.Current) {
                         case PlayerState.Paused:
                             announcer.Announce (String.Empty);
                             break;
                         case PlayerState.Playing:
                             AnnounceTrack (ServiceManager.PlayerEngine.CurrentTrack);
                             break;
                     }
                 }
                 break;
         }
     }
 }
예제 #21
0
        private void OnPlayerEvent(PlayerEventArgs args)
        {
            if (((PlayerEventStateChangeArgs)args).Current == PlayerState.Loaded &&
                track_model.Contains (ServiceManager.PlayerEngine.CurrentTrack)) {
                CurrentTrack = ServiceManager.PlayerEngine.CurrentTrack;

                lock (track_model) {
                    // Remove all but 5 played or skipped tracks
                    if (current_track > 5) {
                        for (int i = 0; i < (current_track - 5); i++) {
                            track_model.Remove (track_model[0]);
                        }
                        current_track = 5;
                    }

                    // Set all previous tracks as CanPlay = false
                    foreach (TrackInfo track in track_model) {
                        if (track == CurrentTrack)
                            break;
                        if (track.CanPlay) {
                            track.CanPlay = false;
                        }
                    }
                    OnUpdated ();
                }

                if (TracksLeft <= 2) {
                    Refresh ();
                }
            }
        }
예제 #22
0
        protected virtual void OnEventChanged(PlayerEventArgs args)
        {
            if (args.Event == PlayerEvent.StartOfStream && pending_track != null) {
                Log.DebugFormat ("OnEventChanged called with StartOfStream.  Replacing current_track with pending_track: \"{0}\"",
                                 pending_track.DisplayTrackTitle);
                CurrentTrackTimeStamp = DateTime.Now;
                current_track = pending_track;
                pending_track = null;
            }

            ThreadAssist.ProxyToMain (() => RaiseEventChanged (args));
        }
        void playerEvent_Handler(PlayerEventArgs e)
        {
            if(e.Event == PlayerEvent.StartOfStream && current_track != ServiceManager.PlaybackController.CurrentTrack)
            {
                try {
                    if (current_track != null) {
                        StopTrack (current_track);
                    }

                    Log.Debug("TrackStarted: "+ServiceManager.PlaybackController.CurrentTrack.TrackTitle);
                    Event ev = CreateZgEvent (ServiceManager.PlaybackController.CurrentTrack, Interpretation.Instance.EventInterpretation.AccessEvent);
                    client.InsertEvents (new List<Event> () {ev});

                    current_track = ServiceManager.PlaybackController.CurrentTrack;
                } catch (Exception ex) {
                    Log.Exception (ex);
                }
            }
        }
예제 #24
0
 private void OnPlayerEvent(PlayerEventArgs args)
 {
     ToggleVideoVisibility ();
 }
 /// <summary>
 /// Handles Metadata changes initiating tagging and file spliting
 /// </summary>
 /// <param name="args">
 /// A <see cref="PlayerEventArgs"/> -- not used
 /// </param>
 private void OnMetadata(PlayerEventArgs args)
 {
     if (recording) {
         TrackInfo track = ServiceManager.PlayerEngine.CurrentTrack;
         recorder.AddStreamTags (track, is_splitting_enabled);
     }
 }
 /// <summary>
 /// Handles EndOfStream events and stops recording
 /// </summary>
 /// <param name="args">
 /// A <see cref="PlayerEventArgs"/>
 /// </param>
 private void OnEndOfStream(PlayerEventArgs args)
 {
     if (recording) {
         StopRecording ();
     }
 }
        public void OnPlayerEvent (PlayerEventArgs args)
        {
            switch (args.Event) {
                case PlayerEvent.StartOfStream:
                    can_show_popup = true;
                    break;

                case PlayerEvent.EndOfStream:
                    // only hide the popup when we don't play again after 250ms
                    GLib.Timeout.Add (250, delegate {
                        if (ServiceManager.PlayerEngine.CurrentState != PlayerState.Playing) {
                            can_show_popup = false;
                            HidePopup ();
                         }
                         return false;
                    });
                    break;
            }
        }
        protected virtual void OnEventChanged (PlayerEventArgs args)
        {
            if (args.Event == PlayerEvent.StartOfStream && pending_track != null) {
                Log.DebugFormat ("OnEventChanged called with StartOfStream.  Replacing current_track with pending_track: \"{0}\"",
                                 pending_track.DisplayTrackTitle);
                current_track = pending_track;
                current_uri = pending_uri;
                pending_track = null;
                pending_uri = null;
            }

            if (ThreadAssist.InMainThread) {
                RaiseEventChanged (args);
            } else {
                ThreadAssist.ProxyToMain (delegate {
                    RaiseEventChanged (args);
                });
            }
        }
 /// <summary>
 /// Handles Player state changes and Stops recording if appropriate
 /// </summary>
 /// <param name="args">
 /// A <see cref="PlayerEventArgs"/>
 /// </param>
 private void OnStateChange(PlayerEventArgs args)
 {
     if (ServiceManager.PlayerEngine.CurrentState == PlayerState.Idle && recording) {
         StopRecording ();
     }
 }
예제 #30
0
 private void OnPlayerEvent (PlayerEventArgs args)
 {
     switch (args.Event) {
         case PlayerEvent.Error:
         case PlayerEvent.EndOfStream:
             ToggleAction stop_action = (ToggleAction) this["StopWhenFinishedAction"];
             // Kinda lame, but we don't want to actually reset StopWhenFinished inside the controller
             // since it is also listening to EOS and needs to actually stop playback; we listen here
             // just to keep the UI in sync.
             stop_action.Activated -= OnStopWhenFinishedAction;
             stop_action.Active = false;
             stop_action.Activated += OnStopWhenFinishedAction;
             break;
         case PlayerEvent.StateChange:
             OnPlayerStateChange ((PlayerEventStateChangeArgs)args);
             break;
     }
 }
 private void RaiseEventChanged (PlayerEventArgs args)
 {
     PlayerEventHandler handler = EventChanged;
     if (handler != null) {
         handler (args);
     }
 }
 private void OnPlayerEvent (PlayerEventArgs args)
 {
     UpdateActions ();
 }
        private void OnPlayerEngineEventChanged(PlayerEventArgs args)
        {
            if (args.Event == PlayerEvent.EndOfStream) {
                lyrics_action_group.GetAction ("ShowLyricsAction").Sensitive = false;
                return;
            }
            lyrics_action_group.GetAction ("ShowLyricsAction").Sensitive = true;

            FetchLyrics (ServiceManager.PlayerEngine.CurrentTrack);
        }
예제 #34
0
 private void OnPlayerEvent(PlayerEventArgs args)
 {
     if (args.Event == PlayerEvent.StartOfStream) {
         idle = false;
         LoadCurrentTrack ();
     } else if (args.Event == PlayerEvent.TrackInfoUpdated) {
         LoadCurrentTrack (true);
     } else if (args.Event == PlayerEvent.StateChange && (incoming_track != null || incoming_image != null)) {
         PlayerEventStateChangeArgs state = (PlayerEventStateChangeArgs)args;
         if (state.Current == PlayerState.Idle) {
             if (idle_timeout_id == 0) {
                 idle_timeout_id = GLib.Timeout.Add (100, IdleTimeout);
             }
         }
     }
 }
예제 #35
0
 private void OnPlayerEvent(PlayerEventArgs args)
 {
     SetVolume ();
 }
예제 #36
0
 private void OnPlayerEvent(PlayerEventArgs args)
 {
     ThreadAssist.ProxyToMain (() => {
         UpdateActions ();
     });
 }
예제 #37
0
 private void OnPlayerEvent (PlayerEventArgs args)
 {
     this["AddToPlayQueueAfterAction"].Sensitive = ServiceManager.PlayerEngine.IsPlaying ();
 }