HTML DOM Video currentSrc Property

HTMLWeb DevelopmentFront End Technology

<p>The HTML DOM Video currentSrc property returns a string corresponding to the url of the video.</p><p>Following is the syntax &minus;</p><p>Returning string value</p><pre class="result notranslate">mediaObject.currentSrc</pre><p>Let us see an example of <strong>HTML DOM Video currentSrc</strong> property &minus;</p><h2>Example</h2><!--<p><a href="" target="_blank" rel="nofollow" class="demo"><i class="fa-external-link"></i> Live Demo</a></p>--><pre class="prettyprint notranslate">&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;HTML DOM Video currentSrc&lt;/title&gt; &lt;style&gt; &nbsp; &nbsp;* { &nbsp; &nbsp; &nbsp; padding: 2px; &nbsp; &nbsp; &nbsp; margin:5px; &nbsp; &nbsp;} &nbsp; &nbsp;form { &nbsp; &nbsp; &nbsp; width:70%; &nbsp; &nbsp; &nbsp; margin: 0 auto; &nbsp; &nbsp; &nbsp; text-align: center; &nbsp; &nbsp;} &nbsp; &nbsp;input[type=&quot;button&quot;] { &nbsp; &nbsp; &nbsp; border-radius: 10px; &nbsp; &nbsp;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &nbsp; &nbsp;&lt;form&gt; &nbsp; &nbsp; &nbsp; &lt;fieldset&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;legend&gt;HTML-DOM-Video-currentSrc&lt;/legend&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;video id=&quot;demo&quot; width=&quot;320&quot; controls&gt;&lt;source &nbsp; &nbsp;src=&quot;http://www.tutorialspoint.com/html5/foo.mp4&quot; type=&quot;video/mp4&quot;&gt;&lt;/video&gt;&lt;br&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&quot;button&quot; onclick=&quot;getTrackDetails()&quot; value=&quot;Get URL&quot;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&quot;text&quot; id=&quot;textSelect&quot; placeholder=&quot;Full Name...&quot;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;div id=&quot;divDisplay&quot;&gt;&lt;/div&gt; &nbsp; &nbsp; &nbsp; &lt;/fieldset&gt; &nbsp; &nbsp;&lt;/form&gt; &lt;script&gt; &nbsp; &nbsp;var divDisplay = document.getElementById(&quot;divDisplay&quot;); &nbsp; &nbsp;var textSelect = document.getElementById(&quot;textSelect&quot;); &nbsp; &nbsp;var demo = document.getElementById(&quot;demo&quot;); &nbsp; &nbsp;function getTrackDetails() { &nbsp; &nbsp; &nbsp; if(textSelect.value === &#39;admin&#39;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;divDisplay.textContent = &#39;Video URL: &#39;+demo.currentSrc; &nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;divDisplay.textContent = &#39;Cannot Provide URL, Unauthorized User&#39;; &nbsp; &nbsp;} &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</pre><h2>Output</h2><p>Click <strong>&lsquo;Get URL&rsquo;</strong> button. This access isn&rsquo;t my admin therefore URL won&rsquo;t be visible &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/30356/962.jpg" class="fr-fic fr-dib" width="600" height="328"></p><p>After entering &ldquo;admin&rdquo; as User and clicking <strong>&lsquo;Get URL&rsquo;</strong> button &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/30356/962_1.jpg" class="fr-fic fr-dib" width="600" height="317"></p>
raja
Updated on 30-Oct-2019 07:08:30

Advertisements