javascript - How to play a video when param is active -
i'm using timesheets.js
make smil-presentation.
in javascript console see this:
<div id="slide3" class="transition" smil="active"> <video id="foo" source type="video/mp4" src="foo.mp4"> </div>
the parameter: smil="active"
either active
or done
.
i want play foo.mp4
when smil="active"
i've added this:
<script> $(document).ready(function () { $('#foo').prop('autoplay', true); }); </script>
but plays video when page loaded, when smil="active"
video has ended.
how can fix this?
edit:
this js that fires state = "active":
var state = ""; this.isactive = function() { return (state == "active"); }; this.show = function() { if (state == "active") return; state = "active"; if (0) try { consolelog(domnode.nodename + "#" + domnode.id + " -- show()"); } catch(e) {} self.settargetstate(state); self.dispatchevent("begin"); self.addeventlistener(endevents, onendlistener); self.removeeventlistener(beginevents, onbeginlistener); //if (self.parentnode.timecontainer == "excl") consolelog("show"); };
check if attribute equal active before playing:
$(document).ready(function () { if($('#slide3').attr('smil') == 'active') { $('#foo').prop('autoplay', true); } else { $('#foo').prop('autoplay', false); } });
Comments
Post a Comment