Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Hi guys #2831

Unanswered
anime-kun32 asked this question in Q&A
Hi guys #2831
Dec 4, 2024 · 0 comments
Discussion options

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

<title>Custom 1 Video Player</title> <style> body { margin: 0; overflow: hidden; } .plyr { width: 100vw; height: 100vh; } </style> <script src="https://cdn.jsdelivr.net/npm/plyr@3"></script> <script>
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);
</script> ```
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /