asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
250 stars 98 forks source link

How to get the status of a failed playback #75

Closed TomDmitriev closed 7 years ago

TomDmitriev commented 7 years ago

When I try to play a non-existing media by doing something like this

        channel.play({media: 'sound:nonexisting'}, playback).then(function() {
            console.log('Everything is fine');
        }).catch((err) => {
            console.log('Error>', err);
        });

I never get an error even though in asterisk's logs I can find

WARNING[10620] res_stasis_playback.c: 1481280112.80: Playback failed for sound:nonexisting

I don't know if this is a node-ari-client issue or rather an ari one. I haven't been able to create an issue in https://github.com/asterisk/asterisk repo.

samuelg commented 7 years ago

I'm surprised that play does not send an error status in this case. One thing to try is looking at the playback control object returned after play is called:

channel.play({media: 'sound:nope'}, playback).then(function (playbackControl) {
    console.log(playbackControl.state);  // state will contain the state of the playback
});

That might show some sort of failure state in your case.

FYI, the asterisk repo on github is a mirror only, please see [1] for creating issues against the Asterisk project itself.

[1] https://issues.asterisk.org

TomDmitriev commented 7 years ago

Unfortunately, playbackControl.state isn't different from the one that a successful play has. My work-around is to measure the time period between PlaybackStarted and PlaybackFinished events. I've created an issue in the Asterisk jira, https://issues.asterisk.org/jira/browse/ASTERISK-26661.

samuelg commented 7 years ago

I verified that this is the case. What's more, the state of the playback on the PlaybackFinished event is done. I would say opening an issue against the Asterisk project itself is the correct move at this point.

praiseable commented 4 years ago

I have done some changes at asterisk side code and now i am getting proper response. I can differentiate between actual file played successful and complete and when was unable to play successful then i got error response on PlaybackFinished. I want to share my contribution with asterisk code i am finding a way to do that

pbpraveen1988 commented 3 years ago

@praiseable , can you please provide the code or snippet , I am also facing the same issue.