I have a video that I want to pause after it reaches X seconds.
- I can play the video
I can listen to the currentTime through:
<videogular data-vg-update-time="someFunction($currentTime,$duration)" ...> </videogular>
I can catch the time I'm looking for in a controller:
var controllers = {}; controllers.SomeController = function($scope){ $scope.someFunction($currentTime, $duration){ // this is a total hack method to catch current time // stay in school or you'll write code like this if(Math.round($currentTime) === 6){ // RIGHT HERE. I know the API must be exposing the video obj // but I haven't been able to figure out how to catch it. // // var foo = document.getElementsByTagName('video'); // foo.pause(); } } } myApp.controller(controllers);
Now, clearly there's a better way to come at this problem. It smells terrible that I'm dropping out of angular to evaluate currentTime, and to try to identify to video object. In part, I'm struggling because the object is created through a directive baked into Videogular. My controller+partial looks like:
[continued from above...]
[i.e controllers.SomeController = function($sce, $scope){
// this is the angular controller
$scope.attractConfig = {
sources: [
{src: $sce.trustAsResourceUrl("/video/myVideo.mp4"), type: "video/mp4"}
],
theme: "/bower_components/videogular-themes-default/videogular.css",
plugins: {
poster: "http://www.videogular.com/assets/images/videogular.png"
},
autoPlay: true
};
// and this is the HTML partial
<div data-ng-controller="SomeController as controller">
<videogular data-vg-theme="attractConfig.theme"
data-vg-auto-play="attractConfig.autoPlay"
data-vg-update-time="checkAttractTime($currentTime,$duration)"
data-vg-complete="restartAttract()">
<vg-media data-vg-src="attractConfig.sources"></vg-media>
</videogular>
</div>
I fell like I'm 90% of the way there, but I can't figure out how to, say, directly call pause() or play() when the currentTime hits X seconds. I can't figure out how to target the video object, which appears via directive.