DOM Properties

HTMLMediaElement.currentSrc

Absolute URL of the selected media resource; empty before selection. It may differ from src when source children are used. Read it after source selection, for example when metadata has loaded, to identify the chosen resource. A relative src attribute is not the same as the resolved currentSrc property. The example deliberately uses no source and tests the empty-string case. Example result: true.

Formal Syntax & Structure

html syntaxhtml
media.currentSrc

Return Value

string

Resolved selected-resource URL, or an empty string if no resource is selected.

Working Example

Example Snippethtml
<p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  const media = document.createElement("audio"); document.body.append(media);  result.textContent = media.currentSrc === "";  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference