更新 infowindow-view.js

This commit is contained in:
钟进 2020-06-16 13:27:06 +00:00
parent 2d52f63254
commit c50b638e26

View File

@ -9,8 +9,6 @@ var util = require('../../core/util');
var ESC_KEY = 27; var ESC_KEY = 27;
var player;
/** /**
* Usage: * Usage:
* var infowindow = new Infowindow({ * var infowindow = new Infowindow({
@ -96,7 +94,8 @@ var Infowindow = View.extend({
}, values); }, values);
this.$el.html( this.$el.html(
sanitize.html(this.template(obj), this.model.get('sanitizeTemplate')) // sanitize.html(this.template(obj), this.model.get('sanitizeTemplate'))
sanitize.html(this.template(obj), false)
); );
// Set width and max-height from the model only // Set width and max-height from the model only
@ -119,6 +118,10 @@ var Infowindow = View.extend({
if (this._containsVideo()) { if (this._containsVideo()) {
this._loadVideo(); this._loadVideo();
} }
if (this._containsH5url()) {
this._loadH5url();
}
this._setupClasses(); this._setupClasses();
this._renderScroll(); this._renderScroll();
@ -130,17 +133,31 @@ var Infowindow = View.extend({
}, },
// video add // video add
_containsH5url: function () {
return !!this.$('.js-infowindow').attr('data-h5url');
},
_loadH5url: function () {
var url = this._getCoverURL();
var $urlsrc = this.$('#mainContent');
$urlsrc.attr('src', url);
},
_containsVideo: function () { _containsVideo: function () {
return !!this.$('.js-infowindow').attr('data-video'); return !!this.$('.js-infowindow').attr('data-video');
}, },
_loadVideo: function () { _loadVideo: function () {
this._renderCoverLoader(); //this._renderCoverLoader();
this._startCoverLoader(); //this._startCoverLoader();
var url = this._getCoverURL(); var url = this._getCoverURL();
var $urlsrc = this.$('#target');
$urlsrc.attr('src', url);
/*
if (this._isLoadingFields()) { if (this._isLoadingFields()) {
return; return;
} }
@ -156,6 +173,10 @@ var Infowindow = View.extend({
} else { } else {
this._loadVideoFromUrl(url); this._loadVideoFromUrl(url);
} }
*/
var $urlsrc = this.$('#target');
$urlsrc.attr('src', url);
}, },
_isValidVideoURL: function (url) { _isValidVideoURL: function (url) {
@ -173,28 +194,14 @@ var Infowindow = View.extend({
}, },
_loadVideoFromUrl: function (url) { _loadVideoFromUrl: function (url) {
var $cover = this.$('.js-cover'); var $urlsrc = this.$('#target');
// this._startCoverLoader(); //this._startCoverLoader();
var $v = $('<video class="video-js CDB-infowindow-media-item" controls data-setup="{}" width="100%"> <source src="" </source></video>'); $urlsrc.attr('src', url);
var $video = $('<video id="hls-video" class="video-js vjs-default-skin" controls preload="none" width="100%" height="264" \
poster="http://vjs.zencdn.net/v/oceans.png"> \
<source src="http://video.hulian100.cn:9090/live/S105.m3u8" type="application/x-mpegURL"></video>');
//$cover.append($video);
this._stopCoverLoader();
player = videojs('hls-video'); player = videojs('hls-video');
/*
$video
.load(this._onLoadVideoSuccess)
.error(this._onLoadVideoError)
.attr('src', url);
*/
}, },
_onLoadVideoError: function () { _onLoadVideoError: function () {
@ -632,10 +639,7 @@ var Infowindow = View.extend({
this.model.set('visibility', false); this.model.set('visibility', false);
} }
if (player) { alert("videojs 暂停" );
player.pause();
alert("videojs 暂停" );
}
}, },
/** /**