| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | var app = angular.module('ngWavesurfer', []);app.directive('ngWavesurfer', function () {    return {        restrict: 'E',        link: function ($scope, $element, $attrs) {            $element.css('display', 'block');            var options = angular.extend({ container: $element[0] }, $attrs);            var wavesurfer = WaveSurfer.create(options);            if ($attrs.url) {                wavesurfer.load($attrs.url, $attrs.data || null);            }            $scope.$emit('wavesurferInit', wavesurfer);        }    };});app.controller('PlaylistController', function ($scope) {    var activeUrl = null;    $scope.paused = true;    $scope.$on('wavesurferInit', function (e, wavesurfer) {        $scope.wavesurfer = wavesurfer;        $scope.wavesurfer.on('play', function () {            $scope.paused = false;        });        $scope.wavesurfer.on('pause', function () {            $scope.paused = true;        });        $scope.wavesurfer.on('finish', function () {            $scope.paused = true;            $scope.wavesurfer.seekTo(0);            $scope.$apply();        });    });    $scope.play = function (url) {        if (!$scope.wavesurfer) {            return;        }        activeUrl = url;        $scope.wavesurfer.once('ready', function () {            $scope.wavesurfer.play();            $scope.$apply();        });        $scope.wavesurfer.load(activeUrl);    };    $scope.isPlaying = function (url) {        return url == activeUrl;    };});
 |