S
S
Sergey2015-12-08 12:55:31
JavaScript
Sergey, 2015-12-08 12:55:31

Track variable, not scope?

There is a player object. It has an ended property.
Is it possible to track the change of player.ended in the form of such an example

player = document.getElementsByClassName('player')[0];
scope.video = [МАССИВ];
var
          count = 0,
          length = scope.video.length;

scope.$watch("player.ended", function (newValue, oldValue) {
          if(newValue == oldValue || newValue){
            scope.player.setAttribute('src', scope.video[count++%length]);
            scope.player.play();
          }
        });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
_
_ _, 2015-12-08
@Sergamers

You don't have to do that. Find the desired event on your player and subscribe to it

M
Mikhail Zakharov, 2015-12-08
@cashalot

Of course you can. Just before that, you need to set this variable before and outside the function:
newValue = "";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question