Thanks for the code snippet.

Note that per spec and in our implementation since Firefox 37, replaceTrack
returns a promise.

You need to wait for that promise to be resolved or rejected before making
assumptions on whether it succeeded or not.


Andreas

On 22 Feb 2018 12:58, "Alexander Abagian" <aabag...@gmail.com> wrote:

>
>
>
> Here's test function (sorry for C++ style). "senders" assumed to contain a
> single sender with a single stream.
>
> After replaceTrack() sender.track.readyState stays "ended" while
> newTrack.readyState is "live".
>
> var ReplaceTrack = function(senders_, newTracks_) {
>         var wasReplaced = false;
>         for (var j = 0; j < newTracks_.length; j++) {
>                 var newTrack = newTracks_[j];
>                 for (var i = 0; i < senders_.length; i++) {
>                         var sender = senders_[i];
>                         if (sender.track) {
>                                 if (sender.track.kind == newTrack.kind) {
>                                         console.log("DBG2071
> newTrack.readyState=", newTrack.readyState);
>                                         console.log("DBG2071 " + i + ".
> .." + sender.track.kind + " track has been replaced with :  ", newTrack.id
> + " [" + newTrack.label + "]", "sender.track.readyState=",
> sender.track.readyState, );
>                                         try {
>
> sender.replaceTrack(newTrack);
>                                         } catch (e) {
>                                                 console.error("DBG207
> sender.replaceTrack error : ", e.message);
>                                         }
>                                         console.log("DBG2071 after
> replaceTrack : sender.track.readyState=", sender.track.readyState);
>                                         console.log("DBG2071
> newTrack.readyState=", newTrack.readyState);
>                                         wasReplaced = true;
>                                         break;
>                                 }
>                         }
>                 }
>                 if (wasReplaced) {
>                         break;
>                 }
>         }
>         return wasReplaced;
> };
> _______________________________________________
> dev-media mailing list
> dev-media@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-media
>
_______________________________________________
dev-media mailing list
dev-media@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-media

Reply via email to