增加播放youtube视频
This commit is contained in:
parent
48a8a90bb3
commit
88c5dc58c2
@ -417,6 +417,11 @@ span.swiper-pagination-bullet {
|
|||||||
.gameplay-video {
|
.gameplay-video {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
margin: 7% auto 0px;
|
margin: 7% auto 0px;
|
||||||
|
position: relative;
|
||||||
|
height: 900px;
|
||||||
|
}
|
||||||
|
#video-frame{
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
.gameplay-video img{
|
.gameplay-video img{
|
||||||
width:100%;
|
width:100%;
|
||||||
@ -764,6 +769,11 @@ span.swiper-pagination-bullet {
|
|||||||
.hero-d-layer-inner::-webkit-scrollbar{
|
.hero-d-layer-inner::-webkit-scrollbar{
|
||||||
width: 0;
|
width: 0;
|
||||||
}
|
}
|
||||||
|
.video-mask{
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.hero-d-layer-con {
|
.hero-d-layer-con {
|
||||||
background: url('../img/nft/hero/herodbg@2x.png') no-repeat center top;
|
background: url('../img/nft/hero/herodbg@2x.png') no-repeat center top;
|
||||||
|
@ -52,8 +52,9 @@
|
|||||||
Logout
|
Logout
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="gameplay-video">
|
<div class="gameplay-video" id="gameVideo">
|
||||||
<img src="img/game play/video@2x.png" />
|
<div id="youtube-video"></div>
|
||||||
|
<!-- <img src="img/game play/video@2x.png" class="video-mask" /> -->
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="content gameplay-content">
|
<section class="content gameplay-content">
|
||||||
@ -228,5 +229,50 @@
|
|||||||
<script type="text/javascript" src="./js/pixelRatio.js"></script>
|
<script type="text/javascript" src="./js/pixelRatio.js"></script>
|
||||||
<script type="text/javascript" src="./js/jcchain.js"></script>
|
<script type="text/javascript" src="./js/jcchain.js"></script>
|
||||||
<script type="text/javascript" src="./js/main.js"></script>
|
<script type="text/javascript" src="./js/main.js"></script>
|
||||||
|
<script>
|
||||||
|
$('#gameVideo').click(function () {
|
||||||
|
$('.video-mask').hide()
|
||||||
|
$('#video-frame').show()
|
||||||
|
})
|
||||||
|
var tag = document.createElement('script')
|
||||||
|
|
||||||
|
tag.src = 'https://www.youtube.com/iframe_api'
|
||||||
|
var firstScriptTag = document.getElementsByTagName('script')[0]
|
||||||
|
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag)
|
||||||
|
|
||||||
|
// 3. This function creates an <iframe> (and YouTube player)
|
||||||
|
// after the API code downloads.
|
||||||
|
var player
|
||||||
|
function onYouTubeIframeAPIReady() {
|
||||||
|
player = new YT.Player('youtube-video', {
|
||||||
|
height: '908',
|
||||||
|
width: '1548',
|
||||||
|
videoId: 'od1HDpyMHG0',
|
||||||
|
events: {
|
||||||
|
onReady: onPlayerReady,
|
||||||
|
onStateChange: onPlayerStateChange,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. The API will call this function when the video player is ready.
|
||||||
|
function onPlayerReady(event) {
|
||||||
|
event.target.playVideo()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. The API calls this function when the player's state changes.
|
||||||
|
// The function indicates that when playing a video (state=1),
|
||||||
|
// the player should play for six seconds and then stop.
|
||||||
|
var done = false
|
||||||
|
function onPlayerStateChange(event) {
|
||||||
|
if (event.data == YT.PlayerState.PLAYING && !done) {
|
||||||
|
setTimeout(stopVideo, 6000)
|
||||||
|
done = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function stopVideo() {
|
||||||
|
player.stopVideo()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -56,7 +56,12 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="gameplay-video">
|
<div class="gameplay-video">
|
||||||
<img src="imgMobile/game play/gpyj@2x.png" width="100%" />
|
<div id="youtube-video" />
|
||||||
|
<img
|
||||||
|
src="imgMobile/game play/gpyj@2x.png"
|
||||||
|
id="videoMask"
|
||||||
|
width="100%"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="gameplay-content">
|
<section class="gameplay-content">
|
||||||
@ -234,5 +239,55 @@
|
|||||||
<script type="text/javascript" src="./js/main.js"></script>
|
<script type="text/javascript" src="./js/main.js"></script>
|
||||||
<script type="text/javascript" src="./js/jcchain.js"></script>
|
<script type="text/javascript" src="./js/jcchain.js"></script>
|
||||||
<script type="text/javascript" src="./js/chain.js"></script>
|
<script type="text/javascript" src="./js/chain.js"></script>
|
||||||
|
<script>
|
||||||
|
// $('#gameVideo').click(function () {
|
||||||
|
// $('.video-mask').hide()
|
||||||
|
// $('#video-frame').show()
|
||||||
|
// })
|
||||||
|
|
||||||
|
let width = $('#videoMask').width()
|
||||||
|
let height = $('#videoMask').height()
|
||||||
|
console.log(width, height)
|
||||||
|
var tag = document.createElement('script')
|
||||||
|
|
||||||
|
tag.src = 'https://www.youtube.com/iframe_api'
|
||||||
|
var firstScriptTag = document.getElementsByTagName('script')[0]
|
||||||
|
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag)
|
||||||
|
|
||||||
|
// 3. This function creates an <iframe> (and YouTube player)
|
||||||
|
// after the API code downloads.
|
||||||
|
var player
|
||||||
|
function onYouTubeIframeAPIReady() {
|
||||||
|
player = new YT.Player('youtube-video', {
|
||||||
|
height: height,
|
||||||
|
width: width,
|
||||||
|
videoId: 'od1HDpyMHG0',
|
||||||
|
events: {
|
||||||
|
onReady: onPlayerReady,
|
||||||
|
onStateChange: onPlayerStateChange,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. The API will call this function when the video player is ready.
|
||||||
|
function onPlayerReady(event) {
|
||||||
|
$('#videoMask').hide()
|
||||||
|
event.target.playVideo()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. The API calls this function when the player's state changes.
|
||||||
|
// The function indicates that when playing a video (state=1),
|
||||||
|
// the player should play for six seconds and then stop.
|
||||||
|
var done = false
|
||||||
|
function onPlayerStateChange(event) {
|
||||||
|
if (event.data == YT.PlayerState.PLAYING && !done) {
|
||||||
|
setTimeout(stopVideo, 6000)
|
||||||
|
done = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function stopVideo() {
|
||||||
|
player.stopVideo()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user