void IExtensionService.Initialize()
        {
            account = LastfmCore.Account;

            if (account.UserName == null)
            {
                account.UserName    = LastUserSchema.Get();
                account.SessionKey  = LastSessionKeySchema.Get();
                account.ScrobbleUrl = LastScrobbleUrlSchema.Get();
            }

            if (LastfmCore.UserAgent == null)
            {
                LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent;
            }

            Browser.Open = Banshee.Web.Browser.Open;

            queue = new Queue();
            LastfmCore.AudioscrobblerQueue = queue;
            connection = LastfmCore.Audioscrobbler;

            Network network = ServiceManager.Get <Network> ();

            connection.UpdateNetworkState(network.Connected);
            network.StateChanged += delegate(object o, NetworkStateChangedArgs args) {
                connection.UpdateNetworkState(args.Connected);
            };

            // Update the Visit action menu item if we update our account info
            LastfmCore.Account.Updated += delegate(object o, EventArgs args) {
                actions["AudioscrobblerVisitAction"].Sensitive = String.IsNullOrEmpty(LastfmCore.Account.UserName);
            };

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.EndOfStream |
                                                     PlayerEvent.Seek |
                                                     PlayerEvent.Iterate);

            action_service = ServiceManager.Get <InterfaceActionService> ("InterfaceActionService");
            InterfaceInitialize();
        }
Beispiel #2
0
        void IExtensionService.Initialize()
        {
            account = LastfmCore.Account;

            if (account.UserName == null)
            {
                account.UserName    = LastfmSource.LastUserSchema.Get();
                account.SessionKey  = LastfmSource.LastSessionKeySchema.Get();
                account.ScrobbleUrl = LastScrobbleUrlSchema.Get();
            }

            if (LastfmCore.UserAgent == null)
            {
                LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent;
            }

            Browser.Open = Banshee.Web.Browser.Open;

            queue = new Queue();
            LastfmCore.AudioscrobblerQueue = queue;
            connection = LastfmCore.Audioscrobbler;

            // Initialize with a reasonable value in case we miss the first StartOfStream event
            song_start_time = DateTime.Now;

            Network network = ServiceManager.Get <Network> ();

            connection.UpdateNetworkState(network.Connected);
            network.StateChanged += HandleNetworkStateChanged;

            connection.SubmissionStart  += OnSubmissionStart;
            connection.SubmissionUpdate += OnSubmissionUpdate;
            connection.SubmissionEnd    += OnSubmissionEnd;

            // Update the Visit action menu item if we update our account info
            LastfmCore.Account.Updated += delegate(object o, EventArgs args) {
                actions["AudioscrobblerVisitAction"].Sensitive = String.IsNullOrEmpty(LastfmCore.Account.UserName);
            };

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.EndOfStream |
                                                     PlayerEvent.Seek |
                                                     PlayerEvent.Iterate);

            if (DeviceEnabled)
            {
                SubscribeForDeviceEvents();
            }

            action_service = ServiceManager.Get <InterfaceActionService> ();
            InterfaceInitialize();
        }
Beispiel #3
0
 private void HandleNetworkStateChanged(object o, NetworkStateChangedArgs args)
 {
     connection.UpdateNetworkState(args.Connected);
 }