Add a directive to control the playback state of media elements.

This commit is contained in:
Paulo Reis 2017-02-09 15:44:15 +00:00
parent d137b00822
commit 1263532271
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,16 @@
define [
"base"
], (App) ->
App.directive "videoPlayState", ($parse) ->
return {
restrict: "A",
link: (scope, element, attrs) ->
videoDOMEl = element[0]
console.dir videoDOMEl
scope.$watch (() -> $parse(attrs.videoPlayState)(scope)), (shouldPlay) ->
if shouldPlay
videoDOMEl.currentTime = 0
videoDOMEl.play()
else
videoDOMEl.pause()
}

View file

@ -29,6 +29,7 @@ define [
"directives/stopPropagation" "directives/stopPropagation"
"directives/rightClick" "directives/rightClick"
"directives/expandableTextArea" "directives/expandableTextArea"
"directives/videoPlayState"
"services/queued-http" "services/queued-http"
"filters/formatDate" "filters/formatDate"
"main/event" "main/event"