Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacExtras/iTunes Library/iTunes Library
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS MacExtras Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacExtras/iTunes Library/iTunes Library
This example is the version from Thu, 6th Apr 2016.
Project "iTunes Library.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Function UnhandledException(error As RuntimeException) As Boolean dim ExceptionName as string = Introspection.GetType(error).fullname MsgBox ExceptionName+EndOfLine+error.Message+EndOfLine+join(error.Stack, EndOfLine) Return true End EventHandler
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub DoubleClick() if me.ListIndex >= 0 then dim v as Variant = me.RowTag(me.ListIndex) if v isa iTunesLibraryMediaItemMBS then dim it as iTunesLibraryMediaItemMBS = v dim file as FolderItem = GetFolderItem(it.location, FolderItem.PathTypeURL) if file<>Nil then call NSWorkspaceMBS.selectFile(File) end if dim a as iTunesLibraryArtworkMBS = it.artwork if a<>Nil then dim n as NSImageMBS = a.image if n<>Nil then PicWindow.left = self.left + 20 + self.Width PicWindow.Backdrop = n.CopyPictureWithMask PicWindow.show end if end if end if end if End EventHandler
EventHandler Sub ExpandRow(row As Integer) dim v as Variant = me.RowTag(row) if v = nil then MsgBox "nil" Return end if if v.Type = Variant.TypeObject then if v isa iTunesLibraryMediaItemMBS then Return // ignore elseif v isa iTunesLibraryPlaylistMBS then dim p as iTunesLibraryPlaylistMBS = v dim items() as iTunesLibraryMediaItemMBS = p.items for each item as iTunesLibraryMediaItemMBS in items List.AddRow item.title, item.artist.name List.RowTag(List.LastIndex) = item next else MsgBox Introspection.GetType(v).fullname end if end if if v.Type = Variant.TypeString then Select case v.StringValue case "playlists" dim playlists() as iTunesLibraryPlaylistMBS = library.allPlaylists for each p as iTunesLibraryPlaylistMBS in playlists List.AddFolder p.name List.RowTag(List.LastIndex) = p next case "items" dim items() as iTunesLibraryMediaItemMBS = library.allMediaItems for each item as iTunesLibraryMediaItemMBS in items List.AddRow item.title, item.artist.name List.RowTag(List.LastIndex) = item next else break end select end if End EventHandler
End Control
EventHandler Sub Open() CheckApp dim error as NSErrorMBS library = iTunesLibraryMBS.libraryWithAPIVersion("1.0", error) if library = nil then MsgBox error.LocalizedDescription quit end if List.AddFolder "All Items" List.RowTag(list.LastIndex) = "items" List.AddFolder "All Playlists" List.RowTag(list.LastIndex) = "playlists" End EventHandler
Sub CheckApp() // just a test if you did your job and code signed the app dim n as NSBundleMBS = NSBundleMBS.mainBundle dim f as folderitem = n.bundleFolder dim s as new Shell s.Execute "codesign -v "+f.ShellPath dim r as string = s.Result if instr(r, "is not signed")>0 then MsgBox "Please code sign this app to make it working." quit end if End Sub
Property library As iTunesLibraryMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class PicWindow Inherits Window
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacExtras Plugin.

MBS FileMaker blog