-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Hi guys #2831
Unanswered
anime-kun32
asked this question in
Q&A
Hi guys
#2831
-
Hi I'm trying to add new options in plyr's settings menu , the place were we find speed and caption
does plyr support this if so how do I do this
I tried it doing here ```html
const urlParams = new URLSearchParams(window.location.search);
const videoID = urlParams.get("id");
if (!videoID) {
console.error("No video ID provided in the URL. Add '?id=VIDEO_ID' to the URL.");
}
const baseApiUrl = `https://tt57.biananset.net/_v7/${videoID}/master.m3u8`;
const player = new Plyr("#player", {
controls: [
"play-large", "play", "progress", "current-time", "mute", "volume", "captions",
"settings", "fullscreen"
],
settings: ["captions", "quality", "speed", "audio", "server"], // Custom menus
});
let audioCategory = "sub"; // Default
let selectedServer = "hd-1"; // Default
const servers = ["hd-1", "hd-2", "streamsb", "streamtape"];
function updateSource() {
const apiUrl = `${baseApiUrl}?category=${audioCategory}&server=${selectedServer}`;
player.source = {
type: "video",
sources: [{ src: apiUrl, type: "application/x-mpegURL" }],
};
}
function addCustomControls() {
const audioMenuItems = [
{ label: "Sub", value: "sub", checked: true },
{ label: "Dub", value: "dub" },
];
player.config.settingsMenu.audio = audioMenuItems;
const serverMenuItems = servers.map((server) => ({
label: server,
value: server,
checked: server === selectedServer,
}));
player.config.settingsMenu.server = serverMenuItems;
player.on("settingchanged", (event) => {
if (event.detail.setting === "audio") {
audioCategory = event.detail.value;
updateSource();
}
});
player.on("settingchanged", (event) => {
if (event.detail.setting === "server") {
selectedServer = event.detail.value;
updateSource();
}
});
}
updateSource();
player.on("ready", addCustomControls);
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment