<object>视频加载,在页面不能实现动态赋值, 将<object>标签写在js中延迟加载,解决不能修改的html对象的问题
1、动态创建这个object( <object> )
$scope.videoParam = function () { var oFlash = '<object id="vlc" width="580" height="240" type="application/x-vlc-plugin" pluginspage="http://www.videolan.org/" events="false">' +'<param name="mrl" value="'+ $scope.cameraUrl +'"/>' +'<param value="50" name="volume"/>' +'<param value="true" name="autoplay"/>' +'<param value="false" name="loop"/>' +'<param value="false" name="fullscreen"/>' +'<param value="false" name="controls"/>' +'</object>'; document.getElementById('player').innerHTML = oFlash; }; $scope.videoParam();
2、修改 <object>中param的valure的值
$timeout(function(){ var prmsUel = $scope.cameraUrl; var prms=document.getElementById("vlc").getElementsByTagName("param"); for(var i=0;i<prms.length;i++){ if(prms[i].name=="mrl"){ prms[i].value = prmsUel; } } },200);
$timeout();延迟加载