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 ITunes
- func (i *ITunes) BackTrack() 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) Pause() error
- func (i *ITunes) Play() 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 Playlist
- func (p *Playlist) AddFile(path string) error
- func (p *Playlist) Delete() error
- func (p *Playlist) GetTracks() (*Tracks, error)
- func (p *Playlist) PlayFirstTrack() error
- func (p *Playlist) SearchAlbums(word string) (int, *Tracks, error)
- func (p *Playlist) SearchAll(word string) (int, *Tracks, error)
- func (p *Playlist) SearchArtists(word string) (int, *Tracks, error)
- func (p *Playlist) SearchComposers(word string) (int, *Tracks, error)
- func (p *Playlist) SearchSongNames(word string) (int, *Tracks, error)
- func (p *Playlist) SearchVisible(word string) (int, *Tracks, error)
- func (p *Playlist) SetRepeat(mode int) error
- func (p *Playlist) SetShuffle(val bool) error
- 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) GetDescription() (string, error)
- func (t *Track) GetDuration() (int64, error)
- func (t *Track) GetExcludeFromShuffle() (bool, error)
- func (t *Track) GetGenre() (string, error)
- func (t *Track) GetKind() (string, error)
- func (t *Track) GetLocation() (string, error)
- func (t *Track) GetLylics() (string, error)
- func (t *Track) GetName() (string, error)
- func (t *Track) GetPlayedCount() (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) 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) SetName(val string) error
- func (t *Track) SetPlayedCount(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 Tracks
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 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) 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) 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 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) PlayFirstTrack ¶
PlayFirstTrack starts play the first track in this playlist.
func (*Playlist) SearchAlbums ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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).
type Track ¶
type Track struct {
COM
}
Track is an object to abstract a music track. This is child for Tracks 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) 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) 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) 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 Tracks ¶
type Tracks struct {
COM
}
Tracks is an object to abstract a collection of music track. This is child for Playlist struct and represents IITTrackCollection object in COM interface.
func (*Tracks) GetTrackByIndex ¶
GetTrackByIndex returns Track in t, corresponding to the given index (1-based).