在离子内容更改中,通过javascript的视频标记源无法正常工作

时间:2017-03-31 08:16:14

标签: javascript video ionic-framework

代码:

<video  id='play_video' controls="controls"  width="100%" height="100%" autoplay="autoplay" webkit-playsinline="webkit-playsinline" class="videoPlayer">             
<source id='mp4Source' src="" type="video/mp4"/>
 </video>

的Javascript

var player = document.getElementById('play_video');  
var mp4Vid = document.getElementById('mp4Source');
mp4Vid = "http://scontent-lht6-1.cdninstagram.com/t50.2886-16/10951700_1534409696814630_381716634_n.mp4";
player.load();
player.play();

问题: 视频标签在ion-content.try里面,通过javascript改变源标签的src是行不通的。这是什么解决方案??

2 个答案:

答案 0 :(得分:1)

您必须设置src的{​​{1}}属性:

element
var player = document.getElementById('play_video');
var mp4Vid = document.getElementById('mp4Source');

mp4Vid.src = "http://scontent-lht6-1.cdninstagram.com/t50.2886-16/10951700_1534409696814630_381716634_n.mp4";
player.load();
player.play();

答案 1 :(得分:0)

var player = document.getElementById('play_video');  
var mp4Vid = document.getElementById('mp4Source');

mp4Vid.src = "http://scontent-lht6-1.cdninstagram.com/t50.2886-16/10951700_1534409696814630_381716634_n.mp4";

player.load();
player.play();