As mentioned, this appears to be caused by the removal of the pause immediately after the VideoElementCache plays the video element.
Reverting this reintroduced https://github.com/bbc/VideoContext/pull/54, so the solution was to only pause the element if its associated video/audio node is not in the playing state.
More Details
A VideoElementCacheItem class has been created so a relationship ("link") between a cached video element and the MediaNode it is currently playing can be established.
There was one unexpected consequences to this fix, where the sourceOffset calculation changes:
Previously:
If the sourceOffset = 10 and the start = 5, e.g.
var videoNode = vc.video('./media.mp4', 10, 5);
videoNode.connect(vc.destination);
videoNode.start(5);
videoNode.stop(15);
The video will be visible at 5 seconds on the VideoContext timeline, but the actual media's currentTime will be 15 seconds, so the offset would be start + sourceOffset.
Now:
Using the same setup as above, the video will be visible at 5 seconds on the VideoContext timeline and the actual media's currentTime will be 10 seconds, so equal to the sourceOffset value.
This change seems to be more what I'd expect, but can anyone confirm this is OK?
This fixes (when released) https://github.com/bbc/VideoContext/issues/86, where the video/audio node plays audio when preloading.
You can see/hear the issue here - https://codesandbox.io/embed/priceless-moser-8cyys
As mentioned, this appears to be caused by the removal of the
pause
immediately after theVideoElementCache
plays the video element.Reverting this reintroduced https://github.com/bbc/VideoContext/pull/54, so the solution was to only pause the element if its associated video/audio node is not in the
playing
state.More Details
A
VideoElementCacheItem
class has been created so a relationship ("link") between a cached video element and theMediaNode
it is currently playing can be established.Now, the
VideoElementCache
can check if the video should remain playing before attempting to pause it, getting around https://github.com/bbc/VideoContext/pull/54.Potential issues
There was one unexpected consequences to this fix, where the
sourceOffset
calculation changes:Previously:
If the
sourceOffset
=10
and thestart
=5
, e.g.The video will be visible at
5
seconds on the VideoContext timeline, but the actual media'scurrentTime
will be15
seconds, so the offset would bestart
+sourceOffset
.Now:
Using the same setup as above, the video will be visible at
5
seconds on the VideoContext timeline and the actual media'scurrentTime
will be10
seconds, so equal to thesourceOffset
value.This change seems to be more what I'd expect, but can anyone confirm this is OK?