Documentation ¶
Overview ¶
Package itunes-win enables you to handle iTunes on Windows in Go. This is a thin wrapper of iTunes COM interface.
Note this library doesn't relect all of the methods and the properties of iTunes COM interface.
Initialization must be done first of all by Init. Exit also must be called at the end:
it, err := itunes.Init() defer it.Exit()
For control over iTunes application, use ITunes object returned:
it.Play()
For control over main library playlist, get Playlist via GetMainPlaylist:
p, err := it.GetMainPlaylist() if err != nil { // handle error } p.PlayFirstTrack()
For control over tracks in the playlist, get Tracks via GetTracks. Likewise, you can control each track in the tracks via Track got by GetTrackByIndex or GetTrackByName:
t, err := p.GetTracks() // ... c64, _ := tracks.GetCount() count := int(c64) for i := 1; i <= count; i++ { track, _ := tracks.GetTrackByIndex(i) }
Index ¶
- Constants
- type COM
- type ITPlaylistKind
- type ITRatingKind
- type ITSourceKind
- type ITTrackKind
- type ITUserPlaylistSpecialKind
- type ITVideoKind
- type ITunes
- func (i *ITunes) BackTrack() error
- func (i *ITunes) CreateFolder(name string) (*Playlist, error)
- func (i *ITunes) CreatePlaylist(name string) (*Playlist, error)
- func (i *ITunes) CurrentEncoder() (string, error)
- func (i *ITunes) Exit()
- func (i *ITunes) GetMainPlaylist() (*Playlist, error)
- func (i *ITunes) Mute(val bool) error
- func (i *ITunes) NextTrack() error
- func (i *ITunes) ObjectPersistentID(obj interface{}) (PersistentID, error)
- func (i *ITunes) Pause() error
- func (i *ITunes) Play() error
- func (i *ITunes) Playlist(pid PersistentID) (*Playlist, error)
- func (i *ITunes) Playlists() (*PlaylistCollection, error)
- func (i *ITunes) PreviousTrack() error
- func (i *ITunes) QuitApp() error
- func (i *ITunes) SoundVolume(val int) error
- func (i *ITunes) Stop() error
- func (i *ITunes) SubscribeToPodcast(u string) error
- func (i *ITunes) UpdatePodcastFeeds() error
- type OperationStatus
- type PersistentID
- type Playlist
- func (p *Playlist) AddFile(path string) (*OperationStatus, error)
- func (p *Playlist) AddTrack(track *Track) error
- func (p *Playlist) CreateFolder(name string) (*Playlist, error)
- func (p *Playlist) CreatePlaylist(name string) (*Playlist, error)
- func (p *Playlist) Delete() error
- func (p *Playlist) Duration() (time.Duration, error)
- func (p *Playlist) GetTracks() (*TrackCollection, error)
- func (p *Playlist) IsSmart() (bool, error)
- func (p *Playlist) Kind() ITPlaylistKind
- func (p *Playlist) Parent() (*Playlist, error)
- func (p *Playlist) PlayFirstTrack() error
- func (p *Playlist) SearchAlbums(word string) (int, *TrackCollection, error)
- func (p *Playlist) SearchAll(word string) (int, *TrackCollection, error)
- func (p *Playlist) SearchArtists(word string) (int, *TrackCollection, error)
- func (p *Playlist) SearchComposers(word string) (int, *TrackCollection, error)
- func (p *Playlist) SearchSongNames(word string) (int, *TrackCollection, error)
- func (p *Playlist) SearchVisible(word string) (int, *TrackCollection, error)
- func (p *Playlist) SetParent(parent *Playlist) error
- func (p *Playlist) SetRepeat(mode int) error
- func (p *Playlist) SetShuffle(val bool) error
- func (p *Playlist) Shuffle() (bool, error)
- func (p *Playlist) Size() (uint64, error)
- func (p *Playlist) SpecialKind() (ITUserPlaylistSpecialKind, error)
- type PlaylistCollection
- type Track
- func (t *Track) AddArtwork(file string) error
- func (t *Track) Delete() error
- func (t *Track) GetAlbum() (string, error)
- func (t *Track) GetAlbumArtist() (string, error)
- func (t *Track) GetAlbumRating() (int64, error)
- func (t *Track) GetArtist() (string, error)
- func (t *Track) GetBPM() (int64, error)
- func (t *Track) GetBitRate() (int64, error)
- func (t *Track) GetCategory() (string, error)
- func (t *Track) GetComment() (string, error)
- func (t *Track) GetComposer() (string, error)
- func (t *Track) GetDateAdded() (time.Time, error)
- func (t *Track) GetDescription() (string, error)
- func (t *Track) GetDuration() (int64, error)
- func (t *Track) GetExcludeFromShuffle() (bool, error)
- func (t *Track) GetGenre() (string, error)
- func (t *Track) GetLocation() (string, error)
- func (t *Track) GetLylics() (string, error)
- func (t *Track) GetName() (string, error)
- func (t *Track) GetPersistentIDHigh() (int64, error)
- func (t *Track) GetPersistentIDLow() (int64, error)
- func (t *Track) GetPlayedCount() (int64, error)
- func (t *Track) GetRating() (int64, error)
- func (t *Track) GetRememberBookmark() (bool, error)
- func (t *Track) GetSize() (int64, error)
- func (t *Track) GetTrackNumber() (int64, error)
- func (t *Track) GetURL() (string, error)
- func (t *Track) GetYear() (int64, error)
- func (t *Track) Kind() ITTrackKind
- func (t *Track) Play() error
- func (t *Track) SetAlbum(val string) error
- func (t *Track) SetAlbumRating(val int) error
- func (t *Track) SetArtist(val string) error
- func (t *Track) SetBPM(val int) error
- func (t *Track) SetCategory(val string) error
- func (t *Track) SetComment(val string) error
- func (t *Track) SetComposer(val string) error
- func (t *Track) SetDescription(val string) error
- func (t *Track) SetGenre(val string) error
- func (t *Track) SetLocation(location string) error
- func (t *Track) SetName(val string) error
- func (t *Track) SetPlayedCount(val int) error
- func (t *Track) SetRating(val int) error
- func (t *Track) SetRememberBookmark(val bool) error
- func (t *Track) SetTrackNumber(val int) error
- func (t *Track) SetURL(url string) error
- func (t *Track) SetYear(val int) error
- type TrackCollection
- func (t *TrackCollection) ByIndex(index int) (*Track, error)
- func (t *TrackCollection) ByName(name string) (*Track, error)
- func (t *TrackCollection) ByPersistentID(pid PersistentID) (*Track, error)
- func (t *TrackCollection) ByPlayOrder(order int) (*Track, error)
- func (t *TrackCollection) Count() (int64, error)
Constants ¶
const ( // RepeatOff sets repeat mode off. RepeatOff = iota // RepeatSong repeats the song. RepeatSong // RepeatAll repeats the playlist. RepeatAll )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type COM ¶
type COM struct {
// contains filtered or unexported fields
}
COM is just an abstraction for *ole.IDispatch.
type ITPlaylistKind ¶ added in v0.2.1
type ITPlaylistKind int
const ( ITPlaylistKindUnknown ITPlaylistKind = iota ITPlaylistKindLibrary ITPlaylistKindUser ITPlaylistKindCD ITPlaylistKindDevice ITPlaylistKindRadioTuner )
func (ITPlaylistKind) String ¶ added in v0.2.1
func (i ITPlaylistKind) String() string
type ITRatingKind ¶ added in v0.2.1
type ITRatingKind int
const ( ITRatingKindUser ITRatingKind = iota ITRatingKindComputed )
func (ITRatingKind) String ¶ added in v0.2.1
func (i ITRatingKind) String() string
type ITSourceKind ¶ added in v0.2.1
type ITSourceKind int
const ( ITSourceKindUnknown ITSourceKind = iota ITSourceKindLibrary ITSourceKindIPod ITSourceKindAudioCD ITSourceKindMP3CD ITSourceKindDevice ITSourceKindRadioTuner )
func (ITSourceKind) String ¶ added in v0.2.1
func (i ITSourceKind) String() string
type ITTrackKind ¶ added in v0.2.1
type ITTrackKind int
const ( ITTrackKindUnknown ITTrackKind = iota ITTrackKindFile ITTrackKindCD ITTrackKindURL ITTrackKindDevice )
func (ITTrackKind) String ¶ added in v0.2.1
func (i ITTrackKind) String() string
type ITUserPlaylistSpecialKind ¶ added in v0.2.1
type ITUserPlaylistSpecialKind int
const ( ITUserPlaylistSpecialKindNone ITUserPlaylistSpecialKind = iota ITUserPlaylistSpecialKindPurchasedMusic ITUserPlaylistSpecialKindPartyShuffle ITUserPlaylistSpecialKindPodcasts ITUserPlaylistSpecialKindFolder ITUserPlaylistSpecialKindVideos ITUserPlaylistSpecialKindMusic ITUserPlaylistSpecialKindMovies ITUserPlaylistSpecialKindTVShows ITUserPlaylistSpecialKindAudiobooks )
func (ITUserPlaylistSpecialKind) String ¶ added in v0.2.1
func (i ITUserPlaylistSpecialKind) String() string
type ITVideoKind ¶ added in v0.2.1
type ITVideoKind int
const ( ITVideoKindNone ITVideoKind = iota ITVideoKindMovie ITVideoKindMusicVideo ITVideoKindTVShow )
type ITunes ¶
type ITunes struct {
COM
}
ITunes is an object to abstract top level iTunes application. This represents IiTunes object in COM interface.
func Init ¶
Init initializes COM library and returns ITunes reference. This must be called at the beginning.
func (*ITunes) BackTrack ¶
BackTrack repositions to the beginning of the current track or go to the previous track if already at start of current track.
func (*ITunes) CreateFolder ¶ added in v0.2.1
func (*ITunes) CreatePlaylist ¶ added in v0.2.1
func (*ITunes) CurrentEncoder ¶
CurrentEncoder returns the currently selected encoder (AAC, MP3, AIFF, WAV, etc).
func (*ITunes) Exit ¶
func (i *ITunes) Exit()
Exit does uninitialization of COM library. This must be called at the end.
func (*ITunes) GetMainPlaylist ¶
GetMainPlaylist returns main library playlist, Playlist.
func (*ITunes) Mute ¶
Mute sets sound output mute state, depending on val (true sets mute on, false sets it off).
func (*ITunes) ObjectPersistentID ¶
func (i *ITunes) ObjectPersistentID(obj interface{}) (PersistentID, error)
func (*ITunes) Playlist ¶ added in v0.2.1
func (i *ITunes) Playlist(pid PersistentID) (*Playlist, error)
func (*ITunes) Playlists ¶ added in v0.2.1
func (i *ITunes) Playlists() (*PlaylistCollection, error)
func (*ITunes) PreviousTrack ¶
PreviousTrack returns to the previous track in the current playlist.
func (*ITunes) SoundVolume ¶
SoundVolume sets the sound output volue. You can set from 0 (minimum) to 100 (maximum).
func (*ITunes) SubscribeToPodcast ¶
SubscribeToPodcast subscribes to the specified podcast url u.
func (*ITunes) UpdatePodcastFeeds ¶
UpdatePodcastFeeds updates all podcast feeds.
type OperationStatus ¶ added in v0.2.3
type OperationStatus struct {
COM
}
func (*OperationStatus) GetTracks ¶ added in v0.2.3
func (o *OperationStatus) GetTracks() (*TrackCollection, error)
type PersistentID ¶ added in v0.2.1
type PersistentID uint64
func ParsePersistentID ¶ added in v0.2.1
func ParsePersistentID(str string) (PersistentID, error)
func (PersistentID) High ¶ added in v0.2.1
func (p PersistentID) High() int
func (PersistentID) Low ¶ added in v0.2.1
func (p PersistentID) Low() int
func (PersistentID) String ¶ added in v0.2.1
func (p PersistentID) String() string
type Playlist ¶
type Playlist struct {
COM
}
Playlist is an object to abstract the main library playlist. This is child for ITunes struct and represents IITPlaylist object in COM interface.
func (*Playlist) AddFile ¶
func (p *Playlist) AddFile(path string) (*OperationStatus, error)
AddFile adds path to this playlist.
func (*Playlist) CreateFolder ¶ added in v0.2.1
func (*Playlist) CreatePlaylist ¶ added in v0.2.1
func (*Playlist) GetTracks ¶
func (p *Playlist) GetTracks() (*TrackCollection, error)
GetTracks returns Tracks in this playlist.
func (*Playlist) Kind ¶ added in v0.2.1
func (p *Playlist) Kind() ITPlaylistKind
func (*Playlist) PlayFirstTrack ¶
PlayFirstTrack starts play the first track in this playlist.
func (*Playlist) SearchAlbums ¶
func (p *Playlist) SearchAlbums(word string) (int, *TrackCollection, error)
SearchAlbums searches only the album field of each track. It returns the number of track found, tracks found as *Tracks and error if any.
func (*Playlist) SearchAll ¶
func (p *Playlist) SearchAll(word string) (int, *TrackCollection, error)
SearchAll searches all fields of each track. It returns the number of track found, tracks found as *Tracks and error if any.
func (*Playlist) SearchArtists ¶
func (p *Playlist) SearchArtists(word string) (int, *TrackCollection, error)
SearchArtists searches only the artist field of each track. It returns the number of track found, tracks found as *Tracks and error if any.
func (*Playlist) SearchComposers ¶
func (p *Playlist) SearchComposers(word string) (int, *TrackCollection, error)
SearchComposers searches only the composer field of each track. It returns the number of track found, tracks found as *Tracks and error if any.
func (*Playlist) SearchSongNames ¶
func (p *Playlist) SearchSongNames(word string) (int, *TrackCollection, error)
SearchSongNames searches only the song name field of each track. It returns the number of track found, tracks found as *Tracks and error if any.
func (*Playlist) SearchVisible ¶
func (p *Playlist) SearchVisible(word string) (int, *TrackCollection, error)
SearchVisible searches only the fields with columns that are currently visible in the display for the playlist. It returns the number of track found, tracks found as *Tracks and error if any.
func (*Playlist) SetRepeat ¶
SetRepeat sets playlist repeat mode. Please specify any one of RepeatOff, RepeatSong or RepeatAll.
func (*Playlist) SetShuffle ¶
SetShuffle sets this playlist shuffle mode (played in random order).
func (*Playlist) SpecialKind ¶ added in v0.2.1
func (p *Playlist) SpecialKind() (ITUserPlaylistSpecialKind, error)
type PlaylistCollection ¶ added in v0.2.1
type PlaylistCollection struct {
COM
}
Playlist is an object to abstract the collection of library playlists. This is child for ITunes struct and represents IITPlaylistCollection object in COM interface.
func (*PlaylistCollection) ByIndex ¶ added in v0.2.1
func (p *PlaylistCollection) ByIndex(idx int) (*Playlist, error)
func (*PlaylistCollection) ByName ¶ added in v0.2.1
func (p *PlaylistCollection) ByName(name string) (*Playlist, error)
func (*PlaylistCollection) ByPersistentID ¶ added in v0.2.1
func (p *PlaylistCollection) ByPersistentID(pid PersistentID) (*Playlist, error)
func (*PlaylistCollection) Count ¶ added in v0.2.1
func (p *PlaylistCollection) Count() (int64, error)
type Track ¶
type Track struct {
COM
}
Track is an object to abstract a music track. This is child for Track struct and represents IITTrack object in COM interface.
func (*Track) AddArtwork ¶
AddArtwork adds artwork from an image file to this track.
func (*Track) GetAlbumArtist ¶
GetAlbumArtist returns the name of the album artist of the track.
func (*Track) GetAlbumRating ¶
GetAlbumRating returns the user or computed rating of the album that this track belongs to (0 to 100). If the album rating has never been set, or has been set to 0.
func (*Track) GetBitRate ¶
GetBitRate returns the bit rate of the track (in kbps).
func (*Track) GetCategory ¶
GetCategory returns the category for the track.
func (*Track) GetComment ¶
GetComment returns the comment of the track.
func (*Track) GetComposer ¶
GetComposer returns the composer of the track.
func (*Track) GetDescription ¶
GetDescription returns the description for the track.
func (*Track) GetDuration ¶
GetDuration returns the length of the track.
func (*Track) GetExcludeFromShuffle ¶
GetExcludeFromShuffle true if this track is skipped when shuffling.
func (*Track) GetLocation ¶
GetLocation returns the full path to the file represented by this track.
func (*Track) GetPersistentIDHigh ¶
func (*Track) GetPersistentIDLow ¶
func (*Track) GetPlayedCount ¶
GetPlayedCount returns the number of times the track has been played.
func (*Track) GetRememberBookmark ¶
GetRememberBookmark returns true if playback position is remembered for this track.
func (*Track) GetTrackNumber ¶
GetTrackNumber returns the index of the track on album.
func (*Track) Kind ¶ added in v0.2.1
func (t *Track) Kind() ITTrackKind
GetKind returns the kind of the track in string.
func (*Track) SetAlbumRating ¶
SetAlbumRating sets the user or computed rating of the album that this track belongs to (0 to 100). If the album rating is set to 0, it will be computed based on the ratings of tracks in the album.
func (*Track) SetCategory ¶
SetCategory sets the category for the track.
func (*Track) SetComment ¶
SetComment sets the comment of the track.
func (*Track) SetComposer ¶
SetComposer sets the composer of the track.
func (*Track) SetDescription ¶
SetDescription the description for the track.
func (*Track) SetLocation ¶ added in v0.2.0
func (*Track) SetPlayedCount ¶
SetPlayedCount sets the number of times the track has been played.
func (*Track) SetRememberBookmark ¶
SetRememberBookmark sets whether the playback position is remembered for this track.
func (*Track) SetTrackNumber ¶
SetTrackNumber sets the index of the track on album.
type TrackCollection ¶ added in v0.2.1
type TrackCollection struct {
COM
}
TrackCollection is an object to abstract a collection of music track. This is child for Playlist struct and represents IITTrackCollection object in COM interface.
func (*TrackCollection) ByIndex ¶ added in v0.2.1
func (t *TrackCollection) ByIndex(index int) (*Track, error)
GetTrackByIndex returns Track in t, corresponding to the given index (1-based).
func (*TrackCollection) ByName ¶ added in v0.2.1
func (t *TrackCollection) ByName(name string) (*Track, error)
GetTrackByName returns Track in t with the specified name.
func (*TrackCollection) ByPersistentID ¶ added in v0.2.1
func (t *TrackCollection) ByPersistentID(pid PersistentID) (*Track, error)
GetTrackByName returns Track in t with the specified name.
func (*TrackCollection) ByPlayOrder ¶ added in v0.2.3
func (t *TrackCollection) ByPlayOrder(order int) (*Track, error)
func (*TrackCollection) Count ¶ added in v0.2.1
func (t *TrackCollection) Count() (int64, error)
GetCount returns the number of track in this tracks.