简体   繁体   中英

HTML5/JavaScript Media Player

I was experimenting with the new video HTML tags and I've tried to make a web-based media player. I tried using a file upload box to enter the object that should be played and that didn't work, which meant I had to try using a text box. That worked to a certain extent, which is that the src property of the video would be edited, but it would be impossible to play the media.

My source code is as follows:

<input type="text" value="Path to file" id="med">
<input type="button" value="Play!"onclick="javascript:document.getElementById('vid2').src=document.getElementById('med').value">
<video width=800 height=400 controls id="vid">
    <source src="" id="vid2">
</video>

Looks really unique. I'd check the Javascript first (I don't know Javascript... so embarassing).

This worked perfectly for me:

<input type="text" value="Path to file" id="med">

    <input type="button" value="Play!" onclick="document.getElementById('vid2').src=document.getElementById('med').value;">

    <video width="800" height="400" controls="controls"  src="" id="vid2">

    </video>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM