The HTML DOM Video currentSrc property returns a string corresponding to the url of the video.
Following is the syntax −
Returning string value
mediaObject.currentSrc
Let us see an example of HTML DOM Video currentSrc property −
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video currentSrc</title>
<style>
* {
padding: 2px;
margin:5px;
}
form {
width:70%;
margin: 0 auto;
text-align: center;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Video-currentSrc</legend>
<video id="demo" width="320" controls><source src="https://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br>
<input type="button" onclick="getTrackDetails()" value="Get URL">
<input type="text" id="textSelect" placeholder="Full Name...">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var textSelect = document.getElementById("textSelect");
var demo = document.getElementById("demo");
function getTrackDetails() {
if(textSelect.value === 'admin')
divDisplay.textContent = 'Video URL: '+demo.currentSrc;
else
divDisplay.textContent = 'Cannot Provide URL, Unauthorized User';
}
</script>
</body>
</html>Output
Click ‘Get URL’ button. This access isn’t my admin therefore URL won’t be visible −

After entering “admin” as User and clicking ‘Get URL’ button −
