public override bool Play(string strFile) { try { if (_iTunesApplication == null) { _iTunesApplication = new iTunesAppClass(); _iTunesApplication.OnPlayerPlayEvent += new _IiTunesEvents_OnPlayerPlayEventEventHandler(_iTunesApplication_OnPlayerPlayEvent); _iTunesApplication.OnPlayerStopEvent += new _IiTunesEvents_OnPlayerStopEventEventHandler(_iTunesApplication_OnPlayerStopEvent); _iTunesApplication.OnPlayerPlayingTrackChangedEvent += new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler( _iTunesApplication_OnPlayerPlayingTrackChangedEvent); IITPlaylist playList = null; foreach (IITPlaylist pl in _iTunesApplication.LibrarySource.Playlists) { if (pl.Name.Equals("MediaPortalTemporaryPlaylist")) { playList = pl; break; } } if (playList == null) { _playList = (IITUserPlaylist)_iTunesApplication.CreatePlaylist("MediaPortalTemporaryPlaylist"); } else { _playList = (IITUserPlaylist)playList; } _playList.SongRepeat = ITPlaylistRepeatMode.ITPlaylistRepeatModeOff; } // stop other media which might be active until now. if (g_Player.Playing) { g_Player.Stop(); } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); _started = false; _ended = false; foreach (IITTrack track in _playList.Tracks) { track.Delete(); } _playList.AddFile(strFile); _playList.PlayFirstTrack(); _playerIsPaused = false; _currentFile = strFile; _duration = -1; _currentPosition = -1; _playerState = ITPlayerState.ITPlayerStateStopped; _updateTimer = DateTime.MinValue; UpdateStatus(); _notifyPlaying = true; return(true); } catch (Exception ex) { Log.Error("ITunesPlugin.Play: Exception"); Log.Error(ex); _notifyPlaying = false; _iTunesApplication = null; } return(false); }