playback.go 673 B

1234567891011121314151617181920212223242526272829303132
  1. package action
  2. import (
  3. "errors"
  4. "fmt"
  5. "strings"
  6. )
  7. func PlaybackPacu(filename string, count int, delay int, PaType string) (err error) {
  8. Para := fmt.Sprintf("count=%d,filename=%s,delay=%d,priority=%s", count, strings.Replace(filename, ".wav", "", -1), delay, PaType)
  9. Chan := "Local/0500" //paging pacu
  10. action := map[string]string{
  11. "Action": "Originate",
  12. "Channel": Chan,
  13. "Exten": "000",
  14. "CallerID": PaType,
  15. "Context": "broadcast-playfile",
  16. "Priority": "1",
  17. "Variable": Para,
  18. }
  19. res, _, err := AminInstance.Send(action)
  20. if err != nil {
  21. return err
  22. }
  23. if res["Response"] != "Success" {
  24. return errors.New(res["Message"])
  25. }
  26. return nil
  27. }