The type
property sets or gets the value of the type attribute in a <source> element.
type |
Yes | Yes | Yes | Yes | Yes |
Return the type property.
var v = sourceObject.type
Set the type property.
sourceObject.type=MIME_type
Value | Description |
---|---|
MIME_type | Specifies the MIME type of the media resource. Common MIME types: For video:
|
A String type value representing the MIME type of the media resource.
The following code shows how to return the MIME type of a media resource.
<!DOCTYPE html>
<html>
<body>
<!--from w w w. ja v a 2 s . c o m-->
<audio controls>
<source id="mySource" src="http://java2s.com/style/demo/rain.mp3" type="audio/mpeg">
<source src="horse.ogg" type="audio/ogg">
</audio>
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
var x = document.getElementById("mySource").type;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: