karthika v nair
karthika v nair

Reputation: 41

In ion-content change the source of video tag via javascript is not working

Code :

<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();

Issue: video tag is inside ion-content.try to change the src of source tag via javascript is not working. what is the solution for this??

Upvotes: 0

Views: 687

Answers (2)

bluehipy
bluehipy

Reputation: 2294

You have to set the src attribute of the 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();
<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>

Upvotes: 1

raj peer
raj peer

Reputation: 718

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();

Upvotes: 0

Related Questions