public iLyrics() { InitializeComponent(); iTunesApp = new iTunesLib.iTunesAppClass(); iTunesApp.BrowserWindow.Visible = true; iTunesApp.BrowserWindow.Minimized = false; }
public static iTunesLib.IITUserPlaylist GetiTunesPlaylist(iTunesLib.IiTunes iitApp, string strPlaylist) { IITUserPlaylist returnPlaylist = null; IITPlaylistCollection playlists = iitApp.LibrarySource.Playlists; int numPlaylists = playlists.Count; Object podcastfolder = null; // find the Dopppler Podcasts folder in iTunes foreach (IITPlaylist folder in iitApp.LibrarySource.Playlists) { if (folder.Name == "Doppler Podcasts") { podcastfolder = folder; break; } } if (podcastfolder == null) { podcastfolder = iitApp.CreateFolder("Doppler Podcasts"); } while (numPlaylists != 0) { Object currPlaylist = playlists[numPlaylists]; IITPlaylist tempPlaylist = (IITPlaylist)currPlaylist; // is this a user playlist? if (tempPlaylist.Kind == ITPlaylistKind.ITPlaylistKindUser) { IITUserPlaylist thisPlaylist = (IITUserPlaylist)currPlaylist; if (thisPlaylist.Name == strPlaylist) { returnPlaylist = thisPlaylist; break; } } numPlaylists--; } if (returnPlaylist == null) { returnPlaylist = (IITUserPlaylist)iitApp.CreatePlaylist(strPlaylist); returnPlaylist.set_Parent(ref podcastfolder); //returnPlaylist = GetiTunesPlaylist(iitApp, strPlaylist); } return(returnPlaylist); }
public bool InitializeITunesApp() { this.theITunesApp = null; this.theLibraryPlaylist = null; string errorMessage = string.Empty; try { this.theITunesApp = new iTunesApp(); if (this.theITunesApp == null) { errorMessage = "iTunesApp object is null!"; } else { this.theLibraryPlaylist = this.theITunesApp.LibraryPlaylist; if (this.theLibraryPlaylist == null) { errorMessage = "Library playlist is null!"; } } } catch (Exception ex) { errorMessage = ex.Message; } if (errorMessage.Length > 0) { DialogResult dr = MessageBox.Show("Error initializing iTunes application: " + errorMessage, "Error Initializing iTunes Application", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); if (dr == DialogResult.Retry) { this.InitializeITunesApp(); } } return(this.IsInitialized); }