Beispiel #1
0
func (p *Player) onMessage(bus *gst.Bus, msg *gst.Message) {
	switch msg.GetType() {
	case gst.MESSAGE_EOS:
		p.pipe.SetState(gst.STATE_NULL)
	case gst.MESSAGE_ERROR:
		p.pipe.SetState(gst.STATE_NULL)
		err, debug := msg.ParseError()
		fmt.Printf("Error: %s (debug: %s)\n", err, debug)
	}
}
Beispiel #2
0
func (db *DoubanFM) onMessage(bus *gst.Bus, msg *gst.Message) {
	switch msg.GetType() {
	case gst.MESSAGE_EOS:
		if db.Loop {
			db.gst.NewSource(db.Song.Url)
		} else {
			db.GetSongs(doubanfm.End)
			if db.Empty() {
				db.GetSongs(doubanfm.Last)
			}
			db.gst.NewSource(db.Next().Url)
		}
	case gst.MESSAGE_ERROR:
		s, param := msg.GetStructure()
		log.Println("gst error", msg.GetType(), s, param)
		db.gst.Stop()
	}
}