视频:动态海报不起作用

时间:2016-04-04 20:28:51

标签: javascript angularjs videogular

我正在迭代视频并试图为每个视频动态设置一张海报:

的index.html

<div ng-controller="VideoController as controller" class="carousel-cell carousel__slide" data-ng-repeat="tpl in templates track by $index">
    <div class="videogular-container">
        <videogular vg-theme="controller.config.theme.url">
            <vg-media vg-src="controller.config.sources"
                          vg-tracks="controller.config.tracks"
                          vg-native-controls="true">
            </vg-media>
          <vg-poster
            vg-url="'{{ tpl.image }}'">
          </vg-poster>
          <vg-overlay-play></vg-overlay-play>
        </videogular>
    </div>
</div>

video.controller.js

'use strict';

angular.module('video', [])
.controller('VideoController',
["$sce", function($sce) {

  this.config = {
            preload: "none",
            sources: [
                {src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.mp4"), type: "video/mp4"},
                {src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.webm"), type: "video/webm"},
                {src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.ogg"), type: "video/ogg"}
            ],
            theme: {
                url: "http://www.videogular.com/styles/themes/default/latest/videogular.css"
            }
        };
  ...

但是,呈现的HTML是这样的:

<vg-poster vg-url="'http://example.net/my-dynamica-image.jpg'" class="ng-isolate-scope"><img ng-src="{{ tpl.image }}" ng-class="API.currentState" src="{{ tpl.image }}" class="stop"></vg-poster>

请注意,它适用于vg-ur但不适用于ng-src。

任何线索?

1 个答案:

答案 0 :(得分:1)

指令vg-url期待一个角度表达式,因此您可以保留为tpl.image

<div ng-controller="VideoController as controller" class="carousel-cell carousel__slide" data-ng-repeat="tpl in templates track by $index">
    <div class="videogular-container">
        <videogular vg-theme="controller.config.theme.url">
            <vg-media vg-src="controller.config.sources"
                          vg-tracks="controller.config.tracks"
                          vg-native-controls="true">
            </vg-media>
          <vg-poster
            vg-url="tpl.image">
          </vg-poster>
          <vg-overlay-play></vg-overlay-play>
        </videogular>
    </div>
</div>

http://videogular.com/docs/#/api/com.2fdevs.videogular.plugins.poster.directive:vgPoster