itunes

package
v0.0.0-...-aeb7f60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2017 License: MIT Imports: 5 Imported by: 0

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

View Source
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

func Init() (*ITunes, error)

Init initializes COM library and returns ITunes reference. This must be called at the beginning.

func (*ITunes) BackTrack

func (i *ITunes) BackTrack() error

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

func (i *ITunes) CurrentEncoder() (string, error)

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

func (i *ITunes) GetMainPlaylist() (*Playlist, error)

GetMainPlaylist returns main library playlist, Playlist.

func (*ITunes) Mute

func (i *ITunes) Mute(val bool) error

Mute sets sound output mute state, depending on val (true sets mute on, false sets it off).

func (*ITunes) NextTrack

func (i *ITunes) NextTrack() error

NextTrack advances to the next track in the current playlist.

func (*ITunes) Pause

func (i *ITunes) Pause() error

Pause pauses current track play.

func (*ITunes) Play

func (i *ITunes) Play() error

Play plays the currently targeted track.

func (*ITunes) PreviousTrack

func (i *ITunes) PreviousTrack() error

PreviousTrack returns to the previous track in the current playlist.

func (*ITunes) QuitApp

func (i *ITunes) QuitApp() error

QuitApp makes iTunes appilcation exit.

func (*ITunes) SoundVolume

func (i *ITunes) SoundVolume(val int) error

SoundVolume sets the sound output volue. You can set from 0 (minimum) to 100 (maximum).

func (*ITunes) Stop

func (i *ITunes) Stop() error

Stop stops the playback.

func (*ITunes) SubscribeToPodcast

func (i *ITunes) SubscribeToPodcast(u string) error

SubscribeToPodcast subscribes to the specified podcast url u.

func (*ITunes) UpdatePodcastFeeds

func (i *ITunes) UpdatePodcastFeeds() error

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) AddFile

func (p *Playlist) AddFile(path string) error

AddFile adds path to this playlist.

func (*Playlist) Delete

func (p *Playlist) Delete() error

Delete deletes this playlist.

func (*Playlist) GetTracks

func (p *Playlist) GetTracks() (*Tracks, error)

GetTracks returns Tracks in this playlist.

func (*Playlist) PlayFirstTrack

func (p *Playlist) PlayFirstTrack() error

PlayFirstTrack starts play the first track in this playlist.

func (*Playlist) SearchAlbums

func (p *Playlist) SearchAlbums(word string) (int, *Tracks, 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, *Tracks, 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, *Tracks, 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, *Tracks, 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, *Tracks, 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, *Tracks, 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

func (p *Playlist) SetRepeat(mode int) error

SetRepeat sets playlist repeat mode. Please specify any one of RepeatOff, RepeatSong or RepeatAll.

func (*Playlist) SetShuffle

func (p *Playlist) SetShuffle(val bool) error

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

func (t *Track) AddArtwork(file string) error

AddArtwork adds artwork from an image file to this track.

func (*Track) Delete

func (t *Track) Delete() error

Delete deletes this track.

func (*Track) GetAlbum

func (t *Track) GetAlbum() (string, error)

GetAlbum returns the name of the album containing the track.

func (*Track) GetAlbumArtist

func (t *Track) GetAlbumArtist() (string, error)

GetAlbumArtist returns the name of the album artist of the track.

func (*Track) GetAlbumRating

func (t *Track) GetAlbumRating() (int64, error)

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) GetArtist

func (t *Track) GetArtist() (string, error)

GetArtist returns the name of the artist of the track.

func (*Track) GetBPM

func (t *Track) GetBPM() (int64, error)

GetBPM returns the BPM of the track.

func (*Track) GetBitRate

func (t *Track) GetBitRate() (int64, error)

GetBitRate returns the bit rate of the track (in kbps).

func (*Track) GetCategory

func (t *Track) GetCategory() (string, error)

GetCategory returns the category for the track.

func (*Track) GetComment

func (t *Track) GetComment() (string, error)

GetComment returns the comment of the track.

func (*Track) GetComposer

func (t *Track) GetComposer() (string, error)

GetComposer returns the composer of the track.

func (*Track) GetDescription

func (t *Track) GetDescription() (string, error)

GetDescription returns the description for the track.

func (*Track) GetDuration

func (t *Track) GetDuration() (int64, error)

GetDuration returns the length of the track.

func (*Track) GetExcludeFromShuffle

func (t *Track) GetExcludeFromShuffle() (bool, error)

GetExcludeFromShuffle true if this track is skipped when shuffling.

func (*Track) GetGenre

func (t *Track) GetGenre() (string, error)

GetGenre returns the genre of the track.

func (*Track) GetKind

func (t *Track) GetKind() (string, error)

GetKind returns the kind of the track in string.

func (*Track) GetLocation

func (t *Track) GetLocation() (string, error)

GetLocation returns the full path to the file represented by this track.

func (*Track) GetLylics

func (t *Track) GetLylics() (string, error)

GetLylics returns the lyrics for the track.

func (*Track) GetName

func (t *Track) GetName() (string, error)

GetName returns the name of the track.

func (*Track) GetPlayedCount

func (t *Track) GetPlayedCount() (int64, error)

GetPlayedCount returns the number of times the track has been played.

func (*Track) GetRememberBookmark

func (t *Track) GetRememberBookmark() (bool, error)

GetRememberBookmark returns true if playback position is remembered for this track.

func (*Track) GetSize

func (t *Track) GetSize() (int64, error)

GetSize returns the size of the track (in bytes).

func (*Track) GetTrackNumber

func (t *Track) GetTrackNumber() (int64, error)

GetTrackNumber returns the index of the track on album.

func (*Track) GetURL

func (t *Track) GetURL() (string, error)

GetURL returns the URL of the stream represented by this track.

func (*Track) GetYear

func (t *Track) GetYear() (int64, error)

GetYear returns the year the track was recorded/released.

func (*Track) Play

func (t *Track) Play() error

Play plays this track.

func (*Track) SetAlbum

func (t *Track) SetAlbum(val string) error

SetAlbum sets the name of the album containing the track.

func (*Track) SetAlbumRating

func (t *Track) SetAlbumRating(val int) error

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) SetArtist

func (t *Track) SetArtist(val string) error

SetArtist sets the name of the artist of the track.

func (*Track) SetBPM

func (t *Track) SetBPM(val int) error

SetBPM sets the BPM of the track.

func (*Track) SetCategory

func (t *Track) SetCategory(val string) error

SetCategory sets the category for the track.

func (*Track) SetComment

func (t *Track) SetComment(val string) error

SetComment sets the comment of the track.

func (*Track) SetComposer

func (t *Track) SetComposer(val string) error

SetComposer sets the composer of the track.

func (*Track) SetDescription

func (t *Track) SetDescription(val string) error

SetDescription the description for the track.

func (*Track) SetGenre

func (t *Track) SetGenre(val string) error

SetGenre sets the genre of the track.

func (*Track) SetName

func (t *Track) SetName(val string) error

SetName sets the name of the track.

func (*Track) SetPlayedCount

func (t *Track) SetPlayedCount(val int) error

SetPlayedCount sets the number of times the track has been played.

func (*Track) SetRememberBookmark

func (t *Track) SetRememberBookmark(val bool) error

SetRememberBookmark sets whether the playback position is remembered for this track.

func (*Track) SetTrackNumber

func (t *Track) SetTrackNumber(val int) error

SetTrackNumber sets the index of the track on album.

func (*Track) SetURL

func (t *Track) SetURL(url string) error

SetURL sets the URL of the stream represented by this track.

func (*Track) SetYear

func (t *Track) SetYear(val int) error

SetYear sets the year the track was recorded/released.

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) GetCount

func (t *Tracks) GetCount() (int64, error)

GetCount returns the number of track in this tracks.

func (*Tracks) GetTrackByIndex

func (t *Tracks) GetTrackByIndex(index int) (*Track, error)

GetTrackByIndex returns Track in t, corresponding to the given index (1-based).

func (*Tracks) GetTrackByName

func (t *Tracks) GetTrackByName(name string) (*Track, error)

GetTrackByName returns Track in t with the specified name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL