Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

ILocalTrack.play() doesn’t return a promise #97

Open
quuu opened this issue Oct 24, 2020 · 2 comments
Open

ILocalTrack.play() doesn’t return a promise #97

quuu opened this issue Oct 24, 2020 · 2 comments

Comments

@quuu
Copy link

quuu commented Oct 24, 2020

The original agora API returned a process when .play() or .paused() is called which lets us catch if something bad happened during the call or not.

NG wraps around the base library but doesn't return a promise. Would it be possible to add a Promise return to the .play()?

@rohan-suri
Copy link

I would also like something like this. For context, I would like to error when trying to play as mentioned in this Agora article:
https://docs.agora.io/en/Voice/autoplay_policy_web?platform=Web

stream.play("agora_remote"+ stream.getId(), function(err){
         if (err && err.status !== "aborted"){
                // The playback fails. Guide the user to resume the playback by clicking.            
                document.querySelector("#agora_remote"+ stream.getId()).onclick=function(){
                         stream.resume().then(
                         function (result) {
                               console.log('Resume succeeds: ' + result);
                        }).catch(
                         function (reason) {
                               console.log('Resume fails: ' + reason);
                        });
                }      
        }
 });

@HAHAHA44
Copy link
Collaborator

The SDK internally try to handle all possible situations that may be encountered when calling play.
For autoplay failed, there is a callback you can listen. https://agoraio-community.github.io/AgoraWebSDK-NG/api/en/interfaces/iagorartc.html#onaudioautoplayfailed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants