视频布局打破浏览器后退按钮

时间:2017-03-14 20:54:12

标签: angularjs browser html5-video back videogular

我使用Videogular渲染视频页面,但是在从详细信息页面导航回来时,我得到了如此破坏的布局:

screen shot 2017-03-14 at 20 02 06

实际布局应如下所示:

screen shot 2017-03-14 at 20 02 38

HTML:

<div class="row">

    <div class="col-lg-12">
      <h3 class="page-header">{{videos.length}}</h3>
    </div>

    <div class="col-xs-12 video-list-container">
      <div class="row">
        <div ng-repeat="video in videos track by $index" class="videogular-container video-thumbnail col-xs-4">
          <videogular  class="row" vg-player-ready="vm.onPlayerReady($API, $index)" vg-update-state="vm.onUpdateState($state, $index)">
            <vg-media vg-src="video.sources" vg-tracks="video.tracks" vg-native-controls="true">
            </vg-media>
            <vg-overlay-play></vg-overlay-play>
             <vg-poster vg-url="video.plugins.poster"></vg-poster>
          </videogular>
          <p class="row thumbnail-name" ui-sref="Video({id: video._id})" ng-bind="video.name"></p>
        </div>
      </div>
    </div>

  </div>

控制器:

function LandingCtrl($scope, VideoService, $sce) {
  'ngInject';
  // ViewModel
  const vm = this;

  this.players = [];

  vm.onPlayerReady = function(API, index) {
    vm.players[index] = API;
  };

  vm.onUpdateState = function(state, index) {
    if (state === 'play') {
      // pause other players
      for (var i = 0, l = vm.players.length; i < l; i++) {
        if (i !== index) {
          vm.players[i].pause();
        }
      }
    }
  };

  VideoService.get()
    .then(function(data) {
      var videos = data.data.data.map((video) => {
          return Object.assign(video, {
            url: video.url.replace('videos/', '').replace('.mp4', '')
          })
        }),
        mediaUrl = 'http://res.cloudinary.com/drxrm1mlz/video/upload/v1489491356/';

      $scope.videos = videos.map((video) => {
        return Object.assign(video, {
          sources: [{
            src: $sce.trustAsResourceUrl(mediaUrl + video.url + '.mp4'),
            type: 'video/mp4'
          }],
          theme: {
            url: 'http://www.videogular.com/styles/themes/default/latest/videogular.css'
          }
        });
      });
    }, function(error) {
      console.log('Error occurred' + error);
    });
}

export default {
  name: 'LandingCtrl',
  fn: LandingCtrl
};

有人知道为什么会这样吗?

0 个答案:

没有答案