Audio Player Logic – Fyne Golang GUI tutorial 66

Audio Player Logic – Fyne Golang GUI tutorial 66

Source Code

<div>
<div>package main</div>
<div>import (</div>
<div>    "os"</div>
<div>    "time"</div>
<div>    "github.com/faiface/beep/mp3"</div>
<div>    "github.com/faiface/beep/speaker"</div>
<div>)</div>
<div>func main() {</div>
<div>    // open file</div>
<div>    // underscore mean we are ignoring error</div>
<div>    f, _ := os.Open("hen.mp3")</div>
<div>    // decoding mp3 file</div>
<div>    // 3 outputs</div>
<div>    // stream , format and error</div>
<div>    streamer, format, _ := mp3.Decode(f)</div>
<div>    // activate speakers</div>
<div>    speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))</div>
<div>    // play</div>
<div>    speaker.Play(streamer)</div>
<div>    // looping</div>
<div>    select {}</div>
<div>}</div>
</div>
Download Code

Fyne Golang GUI Course

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: