1. package play
    2. import (
    3. "fmt"
    4. "time"
    5. )
    6. type MP3Player struct {
    7. stat int
    8. progress int
    9. }
    10. func (p *MP3Player)Play(source ,name string) {
    11. fmt.Printf("\nPlaying %s MP3 music from %s\n",name,source)
    12. p.progress =0
    13. for p.progress <100{
    14. time.Sleep(100*time.Millisecond) //假装正在播放
    15. fmt.Printf("the music %s playing\n",name)
    16. p.progress +=10
    17. }
    18. fmt.Printf("\nFinish Playing %s from %s\n",name,source)
    19. }