HTMLMediaElement.currentSrc

您正在阅读此内容的英文版本,因为该语系尚未翻译。 帮助我们翻译此文章吧!

HTMLMediaElement.currentSrc 属性包含所选媒体源的绝对URL路径。例如当程序会根据用户显示器分辨率选择不同媒体文件时会用到这个属性,显然它是只读的。当networkState值为EMPTY时,本属性值为空字符串(empty string).

语法

var mediaUrl = audioObject.currentSrc;

一个 DOMString 对象包含所选媒体源的绝对URL路径。当 networkState == EMPTY时,其值为空字符串(empty string); 否则,它会是 HTMLSourceElement 所包含媒体列表中的一个,或者是 <source> 标签的src 值.

示例

var obj = document.createElement('video');
console.log(obj.currentSrc); // ""

Specifications

Specification Status Comment
HTML Living Standard
HTMLMediaElement.currentSrc
Living Standard No change from HTML5
HTML5
HTMLMediaElement.currentSrc
Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
currentSrcChrome Full support 43Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support YesSafari Full support 6WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

See also