예제 #1
0
파일: mpd.go 프로젝트: woody7527/MuseBot
func (m *MpdBackend) connect() error {
	var err error

	log.Println("   - Connecting to MPD via", m.network, "at address", m.addr)
	m.client, err = mpd.Dial(m.network, m.addr)
	if err != nil {
		return err
	}

	log.Println("   - Connected!")

	m.client.ConsumeMode(true)

	status, err := m.client.Status()
	if err != nil {
		return err
	}

	lastPlaylistVersionA, err := strconv.ParseUint(status["playlist"], 10, 32)
	lastPlaylistVersion = uint32(lastPlaylistVersionA)

	lastPlaybackState = status["state"]
	log.Println("   - MPD playlist version is at: " + status["playlist"])

	lastPlaylist, err = m.PlaybackQueue()
	if err != nil {
		return err
	}

	return nil
}
예제 #2
0
func NewPlayer() *MPDPlayer {
	var player MPDPlayer
	conn, err := mpd.Dial("tcp", "localhost:6600")
	if err != nil {
		log.Fatalln(err)
	}
	conn.Update("")
	conn.Clear()
	player.client = conn
	return &player
}