Reputation: 1385
I am trying to make a page so that I can enter a URL through the input field and on submitting it will play the video. But unfortunately it's not happening like that.
I am working with a local file on my PC.
JavaScript
window.onload=function(){
alert('Your video player is Here');
}
function play(){
var path = document.getElementById("path").value;
document.getElementById('show').innerHTML='<video id="movie" src="'+url+'" height="600px" width="1300px" controls autoplay > </video>';
var player =document.getElementById('movie');
player.load();
alert(''+player.duration);
}
HTML
<input type="text" id="path" placeholder="put movie path"/>
<input type="submit" onclick="play();" value="Play on"/>
<div id="show"></div>
Upvotes: 0
Views: 5174
Reputation: 4275
url variable is not declared. You can rename the path variable to url in order to make it work. Use the code below
<script type="text/javascript">
window.onload=function(){
alert('Your video player is Here');
}
function play(){
var url = document.getElementById("path").value;
document.getElementById('show').innerHTML='<video id="movie" src="'+url+'" height="600px" width="1300px" controls autoplay > </video>';
var player =document.getElementById('movie');
player.load();
alert(''+player.duration);
}
</script>
JSFIDDLE:http://jsfiddle.net/1sug6ucr/
Hope this helps you
Upvotes: 0
Reputation:
You declare a variable called path
to store value from the input field, but then you try to use a variable called url
when changing the video source.
Upvotes: 2