public BansheePlayerData(PlayerEngine source) {
     if (!(source is IVisualizationDataSource))
         throw new ArgumentException("source is not an IVisualizationDataSource");
     
     this.mSource = source;
     this.Active = true;
 }
Esempio n. 2
0
 private bool SwitchToEngine(PlayerEngine switchTo)
 {
     if (active_engine != switchTo)
     {
         Close();
         pending_engine = switchTo;
         Log.DebugFormat("Switching engine to: {0}", switchTo.GetType());
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
        private void CheckPending()
        {
            if (pending_engine != null && pending_engine != active_engine)
            {
                if (active_engine.CurrentState == PlayerState.Idle)
                {
                    Close();
                }

                active_engine  = pending_engine;
                pending_engine = null;
            }
        }
Esempio n. 4
0
        private void OpenCheck(object o, bool play)
        {
            if (CurrentState == PlayerState.NotReady)
            {
                pending_playback_for_not_ready      = o;
                pending_playback_for_not_ready_play = play;
                return;
            }

            SafeUri   uri   = null;
            TrackInfo track = null;

            if (o is SafeUri)
            {
                uri = (SafeUri)o;
            }
            else if (o is TrackInfo)
            {
                track = (TrackInfo)o;
                uri   = track.Uri;
            }
            else
            {
                return;
            }

            if (track != null && (track.MediaAttributes & TrackMediaAttributes.ExternalResource) != 0)
            {
                RaiseEvent(new PlayerEventArgs(PlayerEvent.EndOfStream));
                return;
            }

            PlayerEngine supportingEngine = FindSupportingEngine(uri);

            SwitchToEngine(supportingEngine);
            CheckPending();

            if (track != null)
            {
                active_engine.Open(track);
            }
            else if (uri != null)
            {
                active_engine.Open(uri);
            }

            if (play)
            {
                active_engine.Play();
            }
        }
Esempio n. 5
0
        public void Dispose()
        {
            MetadataService.Instance.HaveResult -= OnMetadataServiceHaveResult;

            foreach (PlayerEngine engine in engines)
            {
                engine.Dispose();
            }

            active_engine  = null;
            default_engine = null;
            pending_engine = null;

            preferred_engine_id = null;

            engines.Clear();
        }
Esempio n. 6
0
        private void InitializeEngine(PlayerEngine engine)
        {
            var handler = EngineBeforeInitialize;

            if (handler != null)
            {
                handler(engine);
            }

            engine.Initialize();
            engine.IsInitialized = true;

            handler = EngineAfterInitialize;
            if (handler != null)
            {
                handler(engine);
            }
        }
Esempio n. 7
0
        void IInitializeService.Initialize()
        {
            preferred_engine_id = EngineSchema.Get();

            if (default_engine == null && engines.Count > 0)
            {
                default_engine = engines[0];
            }

            foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/Banshee/MediaEngine/PlayerEngine"))
            {
                LoadEngine(node);
            }

            if (default_engine != null)
            {
                active_engine = default_engine;
                Log.Debug(Catalog.GetString("Default player engine"), active_engine.Name);
            }
            else
            {
                default_engine = active_engine;
            }

            if (default_engine == null || active_engine == null || engines == null || engines.Count == 0)
            {
                Log.Warning(Catalog.GetString(
                                "No player engines were found. Please ensure Banshee has been cleanly installed."),
                            "Using the featureless NullPlayerEngine.");
                PlayerEngine null_engine = new NullPlayerEngine();
                LoadEngine(null_engine);
                active_engine  = null_engine;
                default_engine = null_engine;
            }

            MetadataService.Instance.HaveResult += OnMetadataServiceHaveResult;

            TrackInfo.IsPlayingMethod = track => IsPlaying(track) &&
                                        track.CacheModelId == CurrentTrack.CacheModelId &&
                                        (track.CacheEntryId == null || track.CacheEntryId.Equals(CurrentTrack.CacheEntryId));
        }
        private void FindSupportingEngine(SafeUri uri)
        {
            foreach (PlayerEngine engine in engines)
            {
                foreach (string extension in engine.ExplicitDecoderCapabilities)
                {
                    if (!uri.AbsoluteUri.EndsWith(extension))
                    {
                        continue;
                    }
                    else if (active_engine != engine)
                    {
                        Close();
                        pending_engine = engine;
                        Log.DebugFormat("Switching engine to: {0}", engine.GetType());
                    }
                    return;
                }
            }

            foreach (PlayerEngine engine in engines)
            {
                foreach (string scheme in engine.SourceCapabilities)
                {
                    bool supported = scheme == uri.Scheme;
                    if (supported && active_engine != engine)
                    {
                        Close();
                        pending_engine = engine;
                        Log.DebugFormat("Switching engine to: {0}", engine.GetType());
                        return;
                    }
                    else if (supported)
                    {
                        return;
                    }
                }
            }
        }
Esempio n. 9
0
        private void LoadEngine(PlayerEngine engine)
        {
            if (!engine.DelayedInitialize)
            {
                InitializeEngine(engine);
            }

            engine.EventChanged += OnEngineEventChanged;

            if (engine.Id == preferred_engine_id)
            {
                DefaultEngine = engine;
            }
            else
            {
                if (active_engine == null)
                {
                    active_engine = engine;
                }
                engines.Add(engine);
            }
        }
Esempio n. 10
0
        private void LoadEngine(PlayerEngine engine)
        {
            if (!engine.DelayedInitialize) {
                InitializeEngine (engine);
            }

            engine.EventChanged += OnEngineEventChanged;

            if (engine.Id == preferred_engine_id) {
                DefaultEngine = engine;
            } else {
                if (active_engine == null) {
                    active_engine = engine;
                }
                engines.Add (engine);
            }
        }
 public void Dispose() {
     this.Active = false;
     this.mSource = null;
 }
 public void Dispose()
 {
     Active = false;
     source = null;
 }
Esempio n. 13
0
        public void Dispose()
        {
            MetadataService.Instance.HaveResult -= OnMetadataServiceHaveResult;

            foreach (PlayerEngine engine in engines) {
                engine.Dispose ();
            }

            active_engine = null;
            default_engine = null;
            pending_engine = null;

            preferred_engine_id = null;

            engines.Clear ();
        }
Esempio n. 14
0
        void IInitializeService.Initialize()
        {
            preferred_engine_id = EngineSchema.Get();

            if (default_engine == null && engines.Count > 0) {
                default_engine = engines[0];
            }

            foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes ("/Banshee/MediaEngine/PlayerEngine")) {
                LoadEngine (node);
            }

            if (default_engine != null) {
                active_engine = default_engine;
                Log.Debug (Catalog.GetString ("Default player engine"), active_engine.Name);
            } else {
                default_engine = active_engine;
            }

            if (default_engine == null || active_engine == null || engines == null || engines.Count == 0) {
                Log.Warning (Catalog.GetString (
                    "No player engines were found. Please ensure Banshee has been cleanly installed."),
                    "Using the featureless NullPlayerEngine.");
                PlayerEngine null_engine = new NullPlayerEngine ();
                LoadEngine (null_engine);
                active_engine = null_engine;
                default_engine = null_engine;
            }

            MetadataService.Instance.HaveResult += OnMetadataServiceHaveResult;

            TrackInfo.IsPlayingMethod = track => IsPlaying (track) &&
                track.CacheModelId == CurrentTrack.CacheModelId &&
                (track.CacheEntryId == null || track.CacheEntryId.Equals (CurrentTrack.CacheEntryId));
        }
Esempio n. 15
0
        private void CheckPending()
        {
            if (pending_engine != null && pending_engine != active_engine) {
                if (active_engine.CurrentState == PlayerState.Idle) {
                    Close ();
                }

                active_engine = pending_engine;
                pending_engine = null;
            }
        }
Esempio n. 16
0
 private bool SwitchToEngine(PlayerEngine switchTo)
 {
     if (active_engine != switchTo) {
         Close ();
         pending_engine = switchTo;
         Log.DebugFormat ("Switching engine to: {0}", switchTo.GetType ());
         return true;
     }
     return false;
 }
Esempio n. 17
0
 private void ConnectOrDisconnect (PlayerEngine engine, bool connect)
 {
     var vis_engine = engine as IVisualizationDataSource;
     if (vis_engine != null) {
         if (connect) {
             vis_engine.DataAvailable += OnVisualizationDataAvailable;
         } else {
             vis_engine.DataAvailable -= OnVisualizationDataAvailable;
         }
     }
 }
Esempio n. 18
0
        private void InitializeEngine(PlayerEngine engine)
        {
            var handler = EngineBeforeInitialize;
            if (handler != null) {
                handler (engine);
            }

            engine.Initialize ();
            engine.IsInitialized = true;

            handler = EngineAfterInitialize;
            if (handler != null) {
                handler (engine);
            }
        }