리스트에서 바로 동영사 재행 하게 만들고있는데 소리를 껏다 켯다 하는거 잘않됩니다
본문
아래 소스처럼 리스트에서 바로 동영상 재생 하게 해놧는데
소리를껏다 켯다 하는 소스를찾아서 잎엿는데 처음 영상은 소리껏다 켯다 잘작동되는데 두번재 동영상 부터 작동 않됩니다.
현재 리스트페이지는 무한 스크롤 사용하고있습니다.
고수님 도와주세요
감사 합니다.
<div class="img-item">
<video id="track" loop controls muted autoplay playsinline preload="auto" playsinline="true" webkit-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="true">
<source src="<?php echo $list[$i]['wr_link1'] ?>"></source>
</video>
<div class="label-sound">
<div class='unmute' onclick="document.getElementById('track').muted = !document.getElementById('track').muted;$(this).toggleClass('mute')"></div>
</div>
<script>
var audioElm = document.getElementById('ambiance'); audioElm.muted = !audioElm.muted;
</script>
</div>
답변 1
<style>
.label-sound {
display: block;
width: 30px;
height: 30px;
}
.label-sound .unmute {
width: 100%;
height: 100%;
background-color: red;
}
</style>
<div class="img-item">
<video loop controls muted autoplay playsinline preload="auto" playsinline="true" webkit-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="true">
<source src="https://www.w3schools.com/html/mov_bbb.mp4"></source>
</video>
<div class="label-sound">
<div class='unmute' onclick="this.closest('.img-item').firstElementChild.muted = !this.closest('.img-item').firstElementChild.muted"></div>
</div>
</div>
<div class="img-item">
<video loop controls muted autoplay playsinline preload="auto" playsinline="true" webkit-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="true">
<source src="https://www.w3schools.com/html/mov_bbb.mp4"></source>
</video>
<div class="label-sound">
<div class='unmute' onclick="this.closest('.img-item').firstElementChild.muted = !this.closest('.img-item').firstElementChild.muted"></div>
</div>
</div>
<div class="img-item">
<video loop controls muted autoplay playsinline preload="auto" playsinline="true" webkit-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="true">
<source src="https://www.w3schools.com/html/mov_bbb.mp4"></source>
</video>
<div class="label-sound">
<div class='unmute' onclick="this.closest('.img-item').firstElementChild.muted = !this.closest('.img-item').firstElementChild.muted"></div>
</div>
</div>