*** id: 12cb6f04-70b9-4d5b-ad17-a09f186579ef title: PlayAction slug: /go/reference/calling/actions/play description: 'The Play Action is used to play audio, TTS, or silence on a call.' max-toc-depth: 3 ---------------- [link]: /docs/server-sdk/v2/go/reference/calling/actions/play ## Relay.Calling.PlayAction This object returned from one of *asynchronous* play methods that represents a playing currently active on a call. ### Methods-submenu #### GetResult Returns the final result of the playing. **Parameters** *None* **Returns** [`Relay.Calling.PlayResult`][link] - Final result of the playing. **Examples** > Start the play and grab the result when it's completed. ```go // MyOnPlayFinished ran when Play Action finishes func MyOnPlayFinished(playAction *signalwire.PlayAction) { result := playAction.GetResult() if result.Successful { signalwire.Log.Info("Play was successful\n") } } resultDial.Call.OnPlayFinished = MyOnPlayFinished playAction, err := resultDial.Call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3") if err != nil { signalwire.Log.Error("Error occurred while trying to play audio\n") } ``` #### GetState Return the current state of the playing. **Parameters** *None* **Returns** `string` - Current state of the playing. **Examples** > Start the play and print the state. ```go playAction, err := resultDial.Call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3") if err != nil { signalwire.Log.Error("Error occurred while trying to play audio\n") } // [...] if playAction.GetState() == signalwire.PlayPlaying { signalwire.Log.Info("Audio is playing") } ``` #### GetCompleted Return `true` if the playing has finished, `false` otherwise. **Parameters** *None* **Returns** `Boolean` - True/False accordingly to the state. **Examples** > Start the play and check if it has finished. ```go playAction, err := resultDial.Call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3") if err != nil { signalwire.Log.Error("Error occurred while trying to Play audio\n") } for ok := true; ok; ok = !(playAction.GetCompleted()) { time.Sleep(1 * time.Second) } ``` #### GetControlID Return the UUID to identify the action. **Parameters** *None* **Returns** `string` - UUID to identify the action. **Examples** > Start a Play Action and print the controlId. ```go playAction, err := resultDial.Call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3") if err != nil { signalwire.Log.Error("Error occurred while trying to Play audio\n") } Signalwire.Log.Info("Play Action ControlID: %s\n", playAction.GetControlID()) ``` #### Stop Stop the action immediately. **Parameters** *None* **Returns** **Examples** > Start the play and stop it. ```go playAction, err := resultDial.Call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3") if err != nil { signalwire.Log.Error("Error occurred while trying to play audio\n") } // do something here playAction.Stop() ```