示例#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
        public void iTunes()
        {
            itunes = new iTunesAppClass();

            aboutToPromptUserToQuitEvent = new _IiTunesEvents_OnAboutToPromptUserToQuitEventEventHandler(itunes_OnAboutToPromptUserToQuitEvent);
            cOMCallsDisabledEvent        = new _IiTunesEvents_OnCOMCallsDisabledEventEventHandler(itunes_OnCOMCallsDisabledEvent);
            cOMCallsEnabledEvent         = new _IiTunesEvents_OnCOMCallsEnabledEventEventHandler(itunes_OnCOMCallsEnabledEvent);
            databaseChangedEvent         = new _IiTunesEvents_OnDatabaseChangedEventEventHandler(itunes_OnDatabaseChangedEvent);
            playerPlayEvent = new _IiTunesEvents_OnPlayerPlayEventEventHandler(itunes_OnPlayerPlayEvent);
            playerPlayingTrackChangedEvent = new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(itunes_OnPlayerPlayingTrackChangedEvent);
            playerStopEvent           = new _IiTunesEvents_OnPlayerStopEventEventHandler(itunes_OnPlayerStopEvent);
            quittingEvent             = new _IiTunesEvents_OnQuittingEventEventHandler(itunes_OnQuittingEvent);
            soundVolumeChangedEvent   = new _IiTunesEvents_OnSoundVolumeChangedEventEventHandler(itunes_OnSoundVolumeChangedEvent);
            userInterfaceEnabledEvent = new _IiTunesEvents_OnUserInterfaceEnabledEventEventHandler(itunes_OnUserInterfaceEnabledEvent);

            // NOTE: did not see any difference in maintaining these individual handler variables
            // as opposed to unregistering -= new handlers in the OnAboutToPromptToQuit handler

            itunes.OnAboutToPromptUserToQuitEvent += aboutToPromptUserToQuitEvent;
            itunes.OnCOMCallsDisabledEvent        += cOMCallsDisabledEvent;
            itunes.OnCOMCallsEnabledEvent         += cOMCallsEnabledEvent;
            itunes.OnDatabaseChangedEvent         += databaseChangedEvent;
            itunes.OnPlayerPlayEvent += playerPlayEvent;
            itunes.OnPlayerPlayingTrackChangedEvent += playerPlayingTrackChangedEvent;
            itunes.OnPlayerStopEvent           += playerStopEvent;
            itunes.OnQuittingEvent             += quittingEvent;
            itunes.OnSoundVolumeChangedEvent   += soundVolumeChangedEvent;
            itunes.OnUserInterfaceEnabledEvent += userInterfaceEnabledEvent;

            AllProps(itunes);

            reset = new ManualResetEvent(false);

            // waiting for iTunes to quit
            reset.WaitOne();
        }
示例#3
0
        public void iTunes()
        {
            itunes = new iTunesAppClass();

            aboutToPromptUserToQuitEvent = new _IiTunesEvents_OnAboutToPromptUserToQuitEventEventHandler(itunes_OnAboutToPromptUserToQuitEvent);
            cOMCallsDisabledEvent = new _IiTunesEvents_OnCOMCallsDisabledEventEventHandler(itunes_OnCOMCallsDisabledEvent);
            cOMCallsEnabledEvent = new _IiTunesEvents_OnCOMCallsEnabledEventEventHandler(itunes_OnCOMCallsEnabledEvent);
            databaseChangedEvent = new _IiTunesEvents_OnDatabaseChangedEventEventHandler(itunes_OnDatabaseChangedEvent);
            playerPlayEvent = new _IiTunesEvents_OnPlayerPlayEventEventHandler(itunes_OnPlayerPlayEvent);
            playerPlayingTrackChangedEvent = new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(itunes_OnPlayerPlayingTrackChangedEvent);
            playerStopEvent = new _IiTunesEvents_OnPlayerStopEventEventHandler(itunes_OnPlayerStopEvent);
            quittingEvent = new _IiTunesEvents_OnQuittingEventEventHandler(itunes_OnQuittingEvent);
            soundVolumeChangedEvent = new _IiTunesEvents_OnSoundVolumeChangedEventEventHandler(itunes_OnSoundVolumeChangedEvent);
            userInterfaceEnabledEvent = new _IiTunesEvents_OnUserInterfaceEnabledEventEventHandler(itunes_OnUserInterfaceEnabledEvent);

            // NOTE: did not see any difference in maintaining these individual handler variables
            // as opposed to unregistering -= new handlers in the OnAboutToPromptToQuit handler

            itunes.OnAboutToPromptUserToQuitEvent += aboutToPromptUserToQuitEvent;
            itunes.OnCOMCallsDisabledEvent += cOMCallsDisabledEvent;
            itunes.OnCOMCallsEnabledEvent += cOMCallsEnabledEvent;
            itunes.OnDatabaseChangedEvent += databaseChangedEvent;
            itunes.OnPlayerPlayEvent += playerPlayEvent;
            itunes.OnPlayerPlayingTrackChangedEvent += playerPlayingTrackChangedEvent;
            itunes.OnPlayerStopEvent += playerStopEvent;
            itunes.OnQuittingEvent += quittingEvent;
            itunes.OnSoundVolumeChangedEvent += soundVolumeChangedEvent;
            itunes.OnUserInterfaceEnabledEvent += userInterfaceEnabledEvent;

            AllProps(itunes);

            reset = new ManualResetEvent(false);

            // waiting for iTunes to quit
            reset.WaitOne();
        }
示例#4
0
        /// <summary>
        /// Special routine to initialize the base static itunes instance and configure it
        /// for first-time use.
        /// </summary>
        private void InitializeHost()
        {
            bool fresh = !Controller.IsHostRunning;

            try
            {
                Interaction.itunes = new iTunesAppClass();
            }
            catch
            {
                throw new IncompatibleException(Resx.IncompatibleAssemblies);
            }

            Version version = Interaction.itunes.GetType().Assembly.GetName().Version;
            if (!Interaction.itunes.CheckVersion(version.Major, version.Minor))
            {
                string message = String.Format(Resx.IncompatibleVersions,
                    Interaction.itunes.Version, version.Major, version.Minor);

                throw new IncompatibleException(message);
            }

            base.InitializeInteraction();

            Track current = CurrentTrack;
            if (((current == null) || current.PersistentID.IsEmpty) &&
                (PlayerState != ITPlayerState.ITPlayerStatePlaying))
            {
                #region TBD... Future
                //if (Settings.Default.PlayerTrackID > 0)
                //{
                //    IITTrack track =
                //        itunes.LibraryPlaylist.Tracks.get_ItemByPersistentID(
                //        ((PersistentID)Settings.Default.PlayerTrackID).HighBits,
                //        ((PersistentID)Settings.Default.PlayerTrackID).LowBits);

                //    // it appears that we cannot call track.Play().  Something about
                //    //"computer not authorized to play blah blah...
                //    track.Play();
                //    itunes.Pause();
                //}
                //else
                #endregion

                Play();
                Pause();
            }

            this.track = current;

            quitHandler =
                new _IiTunesEvents_OnAboutToPromptUserToQuitEventEventHandler(DoQuit);

            databaseChangedHandler =
                new _IiTunesEvents_OnDatabaseChangedEventEventHandler(DoDatabaseChanged);

            playHandler =
                new _IiTunesEvents_OnPlayerPlayEventEventHandler(DoPlayerPlay);

            trackChangedHandler =
                new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(DoTrackChanged);

            stopHandler =
                new _IiTunesEvents_OnPlayerStopEventEventHandler(DoPlayerStopped);

            volumeHandler =
                new _IiTunesEvents_OnSoundVolumeChangedEventEventHandler(DoSoundVolumeChanged);

            OnAboutToPromptUserToQuitEvent += quitHandler;
            OnDatabaseChangedEvent += databaseChangedHandler;
            OnPlayerPlayEvent += playHandler;
            OnPlayerPlayingTrackChangedEvent += trackChangedHandler;
            OnPlayerStopEvent += stopHandler;
            OnSoundVolumeChangedEvent += volumeHandler;

            if (fresh)
            {
                // if we started iTunes then presume we can minimize it without surprise
                itunes.BrowserWindow.Minimized = true;
            }
        }
示例#5
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;
        }
示例#6
0
        /// <summary>
        /// Special routine to initialize the base static itunes instance and configure it
        /// for first-time use.
        /// </summary>
        private void InitializeHost()
        {
            bool fresh = !Controller.IsHostRunning;

            Interaction.itunes = new iTunesAppClass();

            InitializeInteraction();

            if ((CurrentTrack == null) && (PlayerState != ITPlayerState.ITPlayerStatePlaying))
            {
                #region TBD... Future
                //if (Settings.Default.PlayerTrackID > 0)
                //{
                //    IITTrack track =
                //        itunes.LibraryPlaylist.Tracks.get_ItemByPersistentID(
                //        ((PersistentID)Settings.Default.PlayerTrackID).HighBits,
                //        ((PersistentID)Settings.Default.PlayerTrackID).LowBits);

                //    // it appears that we cannot call track.Play().  Something about
                //    //"computer not authorized to play blah blah...
                //    track.Play();
                //    itunes.Pause();
                //}
                //else
                #endregion

                Play();
                Pause();
            }

            this.track = CurrentTrack;

            quitHandler =
                new _IiTunesEvents_OnAboutToPromptUserToQuitEventEventHandler(DoQuit);

            databaseChangedHandler =
                new _IiTunesEvents_OnDatabaseChangedEventEventHandler(DoDatabaseChanged);

            playHandler =
                new _IiTunesEvents_OnPlayerPlayEventEventHandler(DoPlayerPlay);

            trackChangedHandler =
                new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(DoTrackChanged);

            stopHandler =
                new _IiTunesEvents_OnPlayerStopEventEventHandler(DoPlayerStopped);

            volumeHandler =
                new _IiTunesEvents_OnSoundVolumeChangedEventEventHandler(DoSoundVolumeChanged);

            OnAboutToPromptUserToQuitEvent += quitHandler;
            OnDatabaseChangedEvent += databaseChangedHandler;
            OnPlayerPlayEvent += playHandler;
            OnPlayerPlayingTrackChangedEvent += trackChangedHandler;
            OnPlayerStopEvent += stopHandler;
            OnSoundVolumeChangedEvent += volumeHandler;

            if (fresh)
            {
                // if we started iTunes then presume we can minimize it without surprise
                itunes.BrowserWindow.Minimized = true;
            }
        }
示例#7
0
        /// <summary>
        /// Special routine to initialize the base static itunes instance and configure it
        /// for first-time use.
        /// </summary>

        private void InitializeHost()
        {
            bool fresh = !Controller.IsHostRunning;

            Interaction.itunes = new iTunesAppClass();

            InitializeInteraction();

            if ((CurrentTrack == null) && (PlayerState != ITPlayerState.ITPlayerStatePlaying))
            {
                #region TBD... Future
                //if (Settings.Default.PlayerTrackID > 0)
                //{
                //    IITTrack track =
                //        itunes.LibraryPlaylist.Tracks.get_ItemByPersistentID(
                //        ((PersistentID)Settings.Default.PlayerTrackID).HighBits,
                //        ((PersistentID)Settings.Default.PlayerTrackID).LowBits);

                //    // it appears that we cannot call track.Play().  Something about
                //    //"computer not authorized to play blah blah...
                //    track.Play();
                //    itunes.Pause();
                //}
                //else
                #endregion

                Play();

                Pause();
            }

            this.track = CurrentTrack;

            quitHandler =
                new _IiTunesEvents_OnAboutToPromptUserToQuitEventEventHandler(DoQuit);

            databaseChangedHandler =
                new _IiTunesEvents_OnDatabaseChangedEventEventHandler(DoDatabaseChanged);

            playHandler =
                new _IiTunesEvents_OnPlayerPlayEventEventHandler(DoPlayerPlay);

            trackChangedHandler =
                new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(DoTrackChanged);

            stopHandler =
                new _IiTunesEvents_OnPlayerStopEventEventHandler(DoPlayerStopped);

            volumeHandler =
                new _IiTunesEvents_OnSoundVolumeChangedEventEventHandler(DoSoundVolumeChanged);

            OnAboutToPromptUserToQuitEvent += quitHandler;
            OnDatabaseChangedEvent         += databaseChangedHandler;
            OnPlayerPlayEvent += playHandler;
            OnPlayerPlayingTrackChangedEvent += trackChangedHandler;
            OnPlayerStopEvent         += stopHandler;
            OnSoundVolumeChangedEvent += volumeHandler;

            if (fresh)
            {
                // if we started iTunes then presume we can minimize it without surprise
                itunes.BrowserWindow.Minimized = true;
            }
        }