コード例 #1
0
ファイル: example.go プロジェクト: sdobz/go-mpg123
func main() {
	mpg123.Initialize()
	mp3, err := mpg123.Open("example.mp3")
	if err != nil {
		panic(err)
	}

	rate, channels, encoding, format := mp3.Format()
	fmt.Printf("Rate: %i Channels: %i Encoding: %i Format: %s\n", rate, channels, encoding, format)

	p, err := audio.NewPlayer(fakers, audio.Format(format), rate)
	if err != nil {
		panic(err)
	}

	p.Play()
	for p.State() == audio.Playing {
		time.Sleep(time.Second)
	}
	mpg123.Exit()
}
コード例 #2
0
func main() {
	mpg123.Initialize()
	gopath := os.Getenv("GOPATH")
	mp3, err := mpg123.Open(gopath + "/src/github.com/Golang-Commons/mediaCommons/mpg123bind/examples/example.mp3")
	if err != nil {
		panic(err)
	}

	rate, channels, encoding, format := mp3.Format()
	fmt.Printf("Rate: %i Channels: %i Encoding: %i Format: %s\n", rate, channels, encoding, format)

	p, err := audio.NewPlayer(mp3, audio.Format(format), rate)
	if err != nil {
		panic(err)
	}

	p.Play()
	for p.State() == audio.Playing {
		time.Sleep(time.Second)
	}
	mpg123.Exit()
}