1. package play
    2. import "fmt"
    3. type Player interface {
    4. Play(source string, name string)
    5. }
    6. var p Player
    7. func PlayAll(source, mytype, name string) {
    8. switch mytype {
    9. case "MP3":
    10. p = &MP3Player{}
    11. case "WAV":
    12. p = &WAVPlayer{}
    13. default:
    14. fmt.Println("UnSported music type", mytype)
    15. return
    16. }
    17. p.Play(source, name)
    18. }