Open Windows Media Player Via Html
How can I open windows media player and play a mp3 file via a html file? I don't want to embed the mp3 with
Solution 1:
You can create hidden frame for this, note that only in IE browser it will actually cause WMP to pop up and play it, other browsers will play it "internally".
In the example the code will play file given inside textbox:
File: <input type="text" id="txtMusicFileName" /><br />
<button type="button" onclick="PlayMusicClicked();">Play</button>
JavaScript code required:
<script type="text/javascript">
function PlayMusicClicked() {
var sFileName = document.getElementById("txtMusicFileName").value;
if (sFileName.length > 3) {
var oFrame = document.getElementById("MusicFrame");
if (!oFrame) {
oFrame = document.createElement("iframe");
oFrame.id = "MusicFrame";
oFrame.style.display = "none";
document.body.appendChild(oFrame);
}
oFrame.src = sFileName;
}
}
</script>
Post a Comment for "Open Windows Media Player Via Html"