예제 #1
0
        protected override void Cleanup()
        {
            if (timer != null)
            {
                timer.Elapsed -= new ElapsedEventHandler(DoUpdatePlayer);
                timer.Dispose();
                timer = null;
            }

            if (librarian != null)
            {
                librarian.Dispose();
                librarian = null;
            }

            if (engine != null)
            {
                engine.LyricsUpdated        -= new TrackHandler(DoLyricsUpdated);
                engine.LyricsProgressReport -= new LyricEngineProgress(DoLyricsProgressReport);
                engine.Dispose();
                engine = null;
            }

            if (track != null)
            {
                Release(track);
            }

            try
            {
                OnAboutToPromptUserToQuitEvent -= quitHandler;
                OnDatabaseChangedEvent         -= databaseChangedHandler;
                OnPlayerPlayEvent -= playHandler;
                OnPlayerPlayingTrackChangedEvent -= trackChangedHandler;
                OnPlayerStopEvent         -= stopHandler;
                OnSoundVolumeChangedEvent -= volumeHandler;
            }
            catch
            {
                // no-op
                // Might happen if Alt-F4 is used to close the AppWindow
            }

            quitHandler            = null;
            databaseChangedHandler = null;
            playHandler            = null;
            trackChangedHandler    = null;
            stopHandler            = null;
            volumeHandler          = null;
        }
예제 #2
0
        //========================================================================================
        // Constructor
        //========================================================================================
        /// <summary>
        /// Initialize a new iTunesAppClass safe wrapper.
        /// </summary>
        public Controller()
            : base()
        {
            InitializeHost();

            this.engine = LyricEngine.CreateEngine();
            this.engine.LyricsUpdated += new TrackHandler(DoLyricsUpdated);
            this.engine.LyricsProgressReport += new LyricEngineProgress(DoLyricsProgressReport);

            if (this.track != null)
            {
                if (!this.track.HasLyrics && NetworkStatus.IsAvailable)
                {
                    this.engine.RetrieveLyrics(this.track);
                }
            }

            this.librarian = Librarian.Create(this);

            this.timer = new Timer(1000);
            this.timer.Elapsed += new ElapsedEventHandler(DoUpdatePlayer);
            this.timer.Enabled = IsPlaying;
        }
예제 #3
0
        //========================================================================================
        // Constructor
        //========================================================================================

        /// <summary>
        /// Initialize a new iTunesAppClass safe wrapper.
        /// </summary>

        public Controller()
            : base()
        {
            InitializeHost();

            this.engine = LyricEngine.CreateEngine();
            this.engine.LyricsUpdated        += new TrackHandler(DoLyricsUpdated);
            this.engine.LyricsProgressReport += new LyricEngineProgress(DoLyricsProgressReport);

            if (this.track != null)
            {
                if (!this.track.HasLyrics && NetworkStatus.IsAvailable)
                {
                    this.engine.RetrieveLyrics(this.track);
                }
            }

            this.librarian = Librarian.Create(this);

            this.timer          = new Timer(1000);
            this.timer.Elapsed += new ElapsedEventHandler(DoUpdatePlayer);
            this.timer.Enabled  = IsPlaying;
        }
예제 #4
0
        protected override void Cleanup(bool finalRelease)
        {
            if (timer != null)
            {
                timer.Elapsed -= new ElapsedEventHandler(DoUpdatePlayer);
                timer.Dispose();
                timer = null;
            }

            if (librarian != null)
            {
                librarian.Dispose();
                librarian = null;
            }

            if (engine != null)
            {
                engine.LyricsUpdated -= new TrackHandler(DoLyricsUpdated);
                engine.LyricsProgressReport -= new LyricEngineProgress(DoLyricsProgressReport);
                engine.Dispose();
                engine = null;
            }

            if (track != null)
            {
                Release(track);
            }

            try
            {
                OnAboutToPromptUserToQuitEvent -= quitHandler;
                OnDatabaseChangedEvent -= databaseChangedHandler;
                OnPlayerPlayEvent -= playHandler;
                OnPlayerPlayingTrackChangedEvent -= trackChangedHandler;
                OnPlayerStopEvent -= stopHandler;
                OnSoundVolumeChangedEvent -= volumeHandler;
            }
            catch
            {
                // no-op
                // Might happen if Alt-F4 is used to close the AppWindow
            }

            quitHandler = null;
            databaseChangedHandler = null;
            playHandler = null;
            trackChangedHandler = null;
            stopHandler = null;
            volumeHandler = null;
        }
예제 #5
0
        /// <summary>
        /// Factory method returning the singleton engine.
        /// </summary>
        /// <returns></returns>

        public static LyricEngine CreateEngine()
        {
            return(engine ?? (engine = new LyricEngine()));
        }
예제 #6
0
        /// <summary>
        /// Factory method returning the singleton engine.
        /// </summary>
        /// <returns></returns>
        public static LyricEngine CreateEngine()
        {
            if (engine == null)
            {
                engine = new LyricEngine();
            }

            return engine;
        }