Esempio n. 1
0
func addToQueue(track *sconsify.Track) bool {
	if queue.Add(track) == nil {
		return false
	}
	fmt.Fprintf(gui.queueView, "%v\n", track.GetTitle())
	return true
}
Esempio n. 2
0
func (spotify *Spotify) play(trackUri *sconsify.Track) {
	link, err := spotify.session.ParseLink(trackUri.Uri)
	if err != nil {
		return
	}

	track, err := link.Track()
	if err != nil {
		return
	}

	if trackUri.IsPartial() {
		trackUri = sconsify.ToSconsifyTrack(track)
	}

	if !spotify.isTrackAvailable(track) {
		spotify.events.TrackNotAvailable(trackUri)
		return
	}
	player := spotify.session.Player()
	if err := player.Load(track); err != nil {
		return
	}
	player.Play()

	spotify.events.TrackPlaying(trackUri)
	spotify.currentTrack = trackUri
}
Esempio n. 3
0
func (spotify *Spotify) play(trackUri *sconsify.Track) {
	link, err := spotify.session.ParseLink(trackUri.URI)
	if err != nil {
		return
	}

	track, err := link.Track()
	if err != nil {
		return
	}

	if trackUri.IsPartial() {
		trackUri = sconsify.ToSconsifyTrack(track)
	}

	if !spotify.isTrackAvailable(track) {
		if trackUri.IsFromWebApi() {
			retry := trackUri.RetryLoading()
			if retry < 4 {
				go func() {
					time.Sleep(100 * time.Millisecond)
					spotify.events.Play(trackUri)
				}()
				return
			}
		}
		spotify.events.TrackNotAvailable(trackUri)
		return
	}
	player := spotify.session.Player()
	if err := player.Load(track); err != nil {
		return
	}
	player.Play()

	spotify.events.TrackPlaying(trackUri)
	spotify.currentTrack = trackUri
	spotify.paused = false
	return
}
Esempio n. 4
0
func (noui *NoUi) TrackPlaying(track *sconsify.Track) {
	noui.output.Print(fmt.Sprintf("Playing: %v\n", track.GetFullTitle()))
}
Esempio n. 5
0
func (cui *ConsoleUserInterface) TrackNotAvailable(track *sconsify.Track) {
	gui.flash("Not available: " + track.GetTitle())
}
Esempio n. 6
0
func (cui *ConsoleUserInterface) TrackPlaying(track *sconsify.Track) {
	gui.PlayingTrack = track
	gui.setStatus("Playing: " + track.GetFullTitle())
}
Esempio n. 7
0
func (cui *ConsoleUserInterface) TrackPaused(track *sconsify.Track) {
	gui.setStatus("Paused: " + track.GetFullTitle())
}