如何解决YouTube播放列表未在某些浏览器上显示
我有一个youtube脚本,在某些浏览器上效果很好。我付出了一些努力,并意识到在iOS 12.4或更低版本以及某些其他浏览器上无法正常运行。正在为列表创建框架(DIV)且未显示任何内容的问题。有人能帮助我吗。这是我将其放置在https://www.sheffieldvoices.org.uk/videos上的网站。
谢谢。
$(document).ready(function () {
var key = "AIzaSyA........";
var playlistId = "PLv6hpU.........";
var URL = "https://www.googleapis.com/youtube/v3/playlistItems";
var options = {
part: "snippet",key: key,maxResults: 20,playlistId: playlistId,};
loadVids();
function loadVids() {
$.getJSON(URL,options,function (data) {
var id = data.items[0].snippet.resourceId.videoId;
// mainVid(id);
resultsLoop(data);
});
}
function mainVid(id) {
insertYTModal();
addEventListenersToYTModal();
$("#yt_video_hay").html(`
<iframe src="https://www.youtube.com/embed/${id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
`);
}
function insertYTModal() {
$("body").append(`<div class="modal" id="yt_modal_hay">
<div class="modal-overlay modal-toggle"></div>
<div class="modal-wrapper modal-transition">
<button class="modal-close modal-toggle">x</button>
<div class="modal-body">
<div class="modal-content">
<section id="yt_video_hay"></section>
</div>
</div>
</div>
</div>`);
}
function removeYTModal() {
$("#yt_modal_hay").remove();
}
function resultsLoop(data) {
// debugger;
$.each(data.items,function (i,item) {
var thumb = item.snippet.thumbnails.medium.url;
var title = item.snippet.title;
var desc = item.snippet.description.substring(0,100);
var vid = item.snippet.resourceId.videoId;
$(".list-wrapper_hay").append(`
<div class="item" data-key="${vid}">
<img src="${thumb}" alt="" class="thumb">
<div class="details">
<h4>${title}</h4>
<p>${desc}</p>
</div>
</div>
`);
});
}
// CLICK EVENT
$(".list-wrapper_hay").on("click","div",function () {
var id = $(this).attr("data-key");
mainVid(id);
setTimeout(() => {
$("#yt_modal_hay").toggleClass("is-visible");
},100);
});
function addEventListenersToYTModal() {
$(".modal-toggle").on("click",function (e) {
e.preventDefault();
if (
document.querySelector("#yt_modal_hay").classList[1] === "is-visible"
) {
// debugger;
removeYTModal();
}
$("#yt_modal_hay").toggleClass("is-visible");
});
}
});
<div class="list-wrapper_hay"></div>
.list-wrapper_hay {
padding: 20px 10px;
height: 600px;
overflow: auto;
}
.list-wrapper_hay::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}
.list-wrapper_hay::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: rgba(0,0.5);
Box-shadow: 0 0 1px rgba(255,255,0.5);
}
.list-wrapper_hay .item .details h4 {
padding: 0;
margin: 0;
line-height: 1.3;
font-weight: normal;
color: #fff;
}
.list-wrapper_hay .item .details p {
padding: 0;
margin: 0;
line-height: 1.3;
font-weight: normal;
color: #cecece;
font-size: 0.7rem;
}
.list-wrapper_hay .item {
display: -webkit-Box;
display: flex;
-webkit-Box-align: center;
align-items: center;
padding: 8px 12px;
border-radius: 8px;
margin: 0 auto;
cursor: pointer;
overflow: hidden;
}
.list-wrapper_hay .item:hover {
background: #737373;
}
.list-wrapper_hay .thumb {
height: 70px;
border-radius: 4px;
border: none !important;
background: none !important;
line-height: 0 !important;
Box-shadow: none !important;
margin: 0 !important;
position: static !important;
}
.list-wrapper_hay .details {
padding: 8px 12px;
height: 75px;
}
/*
Modal
*/
#yt_modal_hay {
position: fixed;
z-index: 10000; /* 1 */
top: 0;
left: 0;
visibility: hidden;
width: 100%;
height: 100%;
}
#yt_modal_hay.is-visible {
visibility: visible;
}
#yt_modal_hay .modal-overlay {
position: fixed;
z-index: 10;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: hsla(0,0%,0.5);
visibility: hidden;
opacity: 0;
transition: visibility 0s linear 0.3s,opacity 0.3s;
}
#yt_modal_hay.is-visible .modal-overlay {
opacity: 1;
visibility: visible;
transition-delay: 0s;
}
#yt_modal_hay .modal-wrapper {
position: absolute;
z-index: 9999;
top: 50%;
left: 50%;
width: 60%;
background-color: #fff;
Box-shadow: 0 0 1.5em hsla(0,0.35);
transform: translate(-50%,-50%);
border-radius: 6px;
}
#yt_modal_hay .modal-content {
padding: 10px;
}
#yt_modal_hay .modal-close {
position: absolute;
top: -15px;
right: -20px;
color: #000;
border: 0;
font-size: 20px;
background: #fff;
width: 30px;
height: 30px;
padding: 0;
border-radius: 50%;
}
#yt_video_hay iframe {
height: 50vh;
width: 100%;
}
@media only screen and (max-width: 1024px) {
#yt_modal_hay .modal-wrapper {
width: 80%;
}
#yt_video_hay iframe {
height: 500px;
}
}
@media only screen and (max-width: 768px) {
#yt_video_hay iframe {
height: 330px;
}
}
@media only screen and (max-width: 550px) {
#yt_modal_hay .modal-wrapper {
width: 95%;
}
#yt_video_hay iframe {
height: 185px;
}
.list-wrapper_hay .item .details h4 {
font-size: 1em;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。