2016-05-21 6 views
0

私はYouTubeの歌をHTML形式にするのに助けが必要です。基本的に私は自分のウェブサイトの背景で音楽を聴きたいと思っていますが、実際のビデオは見たくありません。オーディオをHTMLファイル

<html> 
<head> 
    <title>MelonRP loading screen</title> 

    <style type="text/css">  
     body { 
     margin:0px; 
     padding:0px; 
     background-color:#000000 
     } 
    </style> 
</head> 
<body> 
    <object style="height:0px; width:0px;"> 
     <embed src="" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAcess="always" width="0" height="0"> 
    </object> 

    <img src="MelonDarkRP.png" style="max-width:100%; max-height:100%;" alt="" /> 
</body> 

+0

を作りましたあなたのものにアップロードするerver、再生/一時停止ボタンを押します。あなたのサーバーに曲がある場合、視聴者はYouTubeからのプルを待つ必要はありません。 – mlegg

答えて

0

この例を見てhttps://jsfiddle.net/mlegg10/576f27a9/2/

(function(){ 
 
\t var playing = !!('ontouchstart' in window) || !!('ontouchstart' in document.documentElement) || !!window.ontouchstart || (!!window.Touch && !!window.Touch.length) || !!window.onmsgesturechange || (window.DocumentTouch && window.document instanceof window.DocumentTouch), 
 
\t snd = document.getElementsByTagName('audio')[0], 
 
\t ctrl = document.getElementById('pauseplay'); 
 
\t playing = !playing; 
 
\t ctrl.title = playing? 'Pause' : 'Play'; 
 
\t if(playing){snd.autoplay = false; ctrl.src = 'http://hamptonsunrise.com/images/pause.png';} 
 
\t ctrl.addEventListener('click', function(){ 
 
\t \t if(playing){ 
 
\t \t \t snd.pause(); 
 
\t \t } else { 
 
\t \t \t snd.play(); 
 
\t \t } 
 
\t \t playing = !playing; 
 
\t \t ctrl.title = playing? 'Pause' : 'Play'; 
 
\t \t ctrl.src = playing? 'http://hamptonsunrise.com/images/pause.png' : 'http://hamptonsunrise.com/images/play.png'; 
 
\t }, false); 
 
})();
audio {visibility: hidden; height: 0; width: 0; position: absolute; top: -300px; left: -300px;} 
 
#pauseplay {float: right; width: 48px; height: 48px; overflow: hidden; cursor: pointer}
<audio controls loop> 
 
<source src="http://hamptonsunrise.com/audio/waves.ogg" type="audio/ogg"> 
 
<source src="http://hamptonsunrise.com/audio/waves.mp3" type="audio/mpeg"> 
 
</audio> 
 
<img id="pauseplay" src="http://hamptonsunrise.com/images/play.png" alt="button" title="Play/Pause">

ライブ例this siteに私は、私は歌を得るために容易になるだろうと思い

関連する問題