From 12635322712c799f8a43ca76b847327517a797cc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 9 Feb 2017 15:44:15 +0000 Subject: [PATCH] Add a directive to control the playback state of media elements. --- .../coffee/directives/videoPlayState.coffee | 16 ++++++++++++++++ services/web/public/coffee/ide.coffee | 1 + 2 files changed, 17 insertions(+) create mode 100644 services/web/public/coffee/directives/videoPlayState.coffee diff --git a/services/web/public/coffee/directives/videoPlayState.coffee b/services/web/public/coffee/directives/videoPlayState.coffee new file mode 100644 index 0000000000..bd7e41e26c --- /dev/null +++ b/services/web/public/coffee/directives/videoPlayState.coffee @@ -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() + } diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 1ce6fdf0b9..0314e9ffd3 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -29,6 +29,7 @@ define [ "directives/stopPropagation" "directives/rightClick" "directives/expandableTextArea" + "directives/videoPlayState" "services/queued-http" "filters/formatDate" "main/event"