Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iTunes・おぼえていますか〜ScriptingBridge今昔物語〜

 iTunes・おぼえていますか〜ScriptingBridge今昔物語〜

417.72KI

August 24, 2024
Tweet

More Decks by 417.72KI

Other Decks in Programming

Transcript

  1. .VTJDI /* * Music.h */ #import <AppKit/AppKit.h> #import <ScriptingBridge/ScriptingBridge.h> @class

    MusicApplication, MusicItem, MusicAirPlayDevice, MusicArtwork, MusicEncoder, MusicEQPreset, MusicPlaylist, MusicAudioCDPlaylist, MusicLibraryPlaylist, MusicRadioTunerPlaylist, MusicSource, MusicSubscriptionPlaylist, MusicTrack, MusicAudioCDTrack, MusicFileTrack, MusicSharedTrack, MusicURLTrack, MusicUserPlaylist, MusicFolderPlaylist, MusicVisual, MusicWindow, MusicBrowserWindow, MusicEQWindow, MusicMiniplayerWindow, MusicPlaylistWindow, MusicVideoWindow; enum MusicEKnd { MusicEKndTrackListing = 'kTrk' /* a basic listing of tracks within a playlist */, MusicEKndAlbumListing = 'kAlb' /* a listing of a playlist grouped by album */, MusicEKndCdInsert = 'kCDi' /* a printout of the playlist for jewel case inserts */ }; typedef enum MusicEKnd MusicEKnd; enum MusicEnum { MusicEnumStandard = 'lwst' /* Standard PostScript error handling */, MusicEnumDetailed = 'lwdt' /* print a detailed report of PostScript errors */ }; typedef enum MusicEnum MusicEnum; enum MusicEPlS { MusicEPlSStopped = 'kPSS', MusicEPlSPlaying = 'kPSP', MusicEPlSPaused = 'kPSp', MusicEPlSFastForwarding = 'kPSF', MusicEPlSRewinding = 'kPSR' }; typedef enum MusicEPlS MusicEPlS;
  2. .VTJDI /* * Music Suite */ // The application program

    @interface MusicApplication : SBApplication - (SBElementArray<MusicPlaylist *> *) playlists; - (SBElementArray<MusicSource *> *) sources; - (SBElementArray<MusicTrack *> *) tracks; @property (copy, readonly) MusicPlaylist *currentPlaylist; // the playlist containing the currently targeted track @property (copy, readonly) MusicTrack *currentTrack; // the current targeted track @property BOOL fullScreen; // is the application using the entire screen? @property (copy, readonly) NSString *name; // the name of the application @property BOOL mute; // has the sound output been muted? @property double playerPosition; // the player’s position within the currently playing track in seconds. @property (readonly) MusicEPlS playerState; // is the player stopped, paused, or playing? @property BOOL shuffleEnabled; // are songs played in random order? @property MusicEShM shuffleMode; // the playback shuffle mode @property MusicERpt songRepeat; // the playback repeat mode @property NSInteger soundVolume; // the sound output volume (0 = minimum, 100 = maximum) @property (copy, readonly) NSString *version; // the version of the application - (void) run; // Run the application - (void) quit; // Quit the application - (void) backTrack; // reposition to beginning of current track or go to previous track if already at start of current track - (void) fastForward; // skip forward in a playing track - (void) nextTrack; // advance to the next track in the current playlist - (void) pause; // pause playback - (void) playOnce:(BOOL)once; // play the current track or the specified track or file. - (void) playpause; // toggle the playing/paused state of the current track - (void) previousTrack; // return to the previous track in the current playlist - (void) resume; // disable fast forward/rewind and resume playback, if playing. - (void) stop; // stop playback @end
  3. .VTJDI // playable audio source @interface MusicTrack : MusicItem -

    (SBElementArray<MusicArtwork *> *) artworks; @property (copy) NSString *album; // the album name of the track @property (copy) NSString *albumArtist; // the album artist of the track @property (copy) NSString *artist; // the artist/source of the track @property (copy) NSString *composer; // the composer of the track @property NSInteger discCount; // the total number of discs in the source album @property NSInteger discNumber; // the index of the disc containing this track on the source album @property (copy) NSString *genre; // the music/audio genre (category) of the track @property (copy) NSString *lyrics; // the lyrics of the track @property (copy) NSString *sortAlbum; // override string to use for the track when sorting by album @property (copy) NSString *sortArtist; // override string to use for the track when sorting by artist @property (copy) NSString *sortAlbumArtist; // override string to use for the track when sorting by album artist @property (copy) NSString *sortName; // override string to use for the track when sorting by name @property (copy) NSString *sortComposer; // override string to use for the track when sorting by composer @property NSInteger trackCount; // the total number of tracks on the source album @property NSInteger trackNumber; // the index of the track on the source album @property NSInteger year; // the year the track was recorded/released @end // a track representing an audio file (MP3, AIFF, etc.) @interface MusicFileTrack : MusicTrack @property (copy) NSURL *location; // the location of the file represented by this track - (void) refresh; // update file track information from the current information in the track’s file @end
  4. 3FTUPSF"SUXPSL func restoreArtwork(for track: MusicTrack) { guard let artworks =

    track.artworks?() else { return } artworks.lazy .compactMap { $0 as? MusicArtwork } .forEach { artwork in guard let data = artwork.data else { return } artwork.setData?(data) } }
  5. .VTJDTXJGU // MARK: MusicTrack @objc public protocol MusicTrack: MusicItem {

    @objc optional func artworks() -> SBElementArray @objc optional var album: String { get } // the album name of the track @objc optional var albumArtist: String { get } // the album artist of the track @objc optional var artist: String { get } // the artist/source of the track @objc optional var composer: String { get } // the composer of the track @objc optional var discCount: Int { get } // the total number of discs in the source album @objc optional var discNumber: Int { get } // the index of the disc containing this track on the source album @objc optional var genre: String { get } // the music/audio genre (category) of the track @objc optional var lyrics: String { get } // the lyrics of the track @objc optional var sortAlbum: String { get } // override string to use for the track when sorting by album @objc optional var sortArtist: String { get } // override string to use for the track when sorting by artist @objc optional var sortAlbumArtist: String { get } // override string to use for the track when sorting by album artist @objc optional var sortName: String { get } // override string to use for the track when sorting by name @objc optional var sortComposer: String { get } // override string to use for the track when sorting by composer @objc optional var trackCount: Int { get } // the total number of tracks on the source album @objc optional var trackNumber: Int { get } // the index of the track on the source album @objc optional var year: Int { get } // the year the track was recorded/released @objc optional func setAlbum(_ album: String) // the album name of the track @objc optional func setAlbumArtist(_ albumArtist: String) // the album artist of the track @objc optional func setAlbumDisliked(_ albumDisliked: Bool) // is the album for this track disliked? @objc optional func setAlbumFavorited(_ albumFavorited: Bool) // is the album for this track favorited? @objc optional func setAlbumRating(_ albumRating: Int) // the rating of the album for this track (0 to 100) @objc optional func setArtist(_ artist: String) // the artist/source of the track @objc optional func setComposer(_ composer: String) // the composer of the track @objc optional func setDiscCount(_ discCount: Int) // the total number of discs in the source album @objc optional func setDiscNumber(_ discNumber: Int) // the index of the disc containing this track on the source album @objc optional func setGenre(_ genre: String) // the music/audio genre (category) of the track @objc optional func setLyrics(_ lyrics: String) // the lyrics of the track @objc optional func setSortAlbum(_ sortAlbum: String) // override string to use for the track when sorting by album @objc optional func setSortArtist(_ sortArtist: String) // override string to use for the track when sorting by artist @objc optional func setSortAlbumArtist(_ sortAlbumArtist: String) // override string to use for the track when sorting by album artist @objc optional func setSortName(_ sortName: String) // override string to use for the track when sorting by name @objc optional func setSortComposer(_ sortComposer: String) // override string to use for the track when sorting by composer @objc optional func setTrackCount(_ trackCount: Int) // the total number of tracks on the source album @objc optional func setTrackNumber(_ trackNumber: Int) // the index of the track on the source album @objc optional func setYear(_ year: Int) // the year the track was recorded/released } extension SBObject: MusicTrack {}
  6. 'JO

  7. TFMGEFTDSJQUJPO struct Me { let name = "Takuhiro Muta" let

    aka = "417.72KI" let twitter = "417_72ki" let qiita = "417_72ki" let gitHub = "417-72KI" let oss = [ "MockUserDefaults", "MultipartDataParser", "BuildConfig.swift", ] let community = [ "love-swift", "potatotips", "Chiba.swift", ] }