-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Player, WebSockets and other bug fixes
1. Player tries to load three times 2. If the channel doesn't have 7tv or BTTV account the corresponding WebSocket will not open 3. Mod actions will now work if the user has them enabled
- Loading branch information
Showing
3 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
<link rel="stylesheet" type="text/css" href="styles/followList.css"> | ||
<link rel="stylesheet" type="text/css" href="styles/styles.css"> | ||
<link rel="stylesheet" type="text/css" href="styles/settings.css"> | ||
<script src="https://player.twitch.tv/js/embed/v1.js"></script> | ||
|
||
<style> | ||
@import url('https://fonts.googleapis.com/css2?family=Inter:[email protected]&display=swap'); | ||
|
@@ -54,7 +53,7 @@ | |
</div> | ||
</div> | ||
<div class="embed"> | ||
<div id="twitch-embed"></div> | ||
<div id="twitch-embed">Refresh if you don't see the player.</div> | ||
<div class="stream-info"> | ||
<div class="stream-title">stream-title</div> | ||
<div class="stream-viewers">0</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,10 @@ async function loadBodyElements(elements) { | |
link.href = 'https://fonts.googleapis.com/css2?family=Inter:[email protected]&display=swap'; | ||
document.head.appendChild(link); | ||
|
||
const script = document.createElement('script'); | ||
script.src = "https://player.twitch.tv/js/embed/v1.js"; | ||
document.head.appendChild(script); | ||
|
||
const twitchEmbed = document.getElementById('twitch-embed'); | ||
if (twitchEmbed) { | ||
console.log('#twitch-embed exists!'); | ||
|
@@ -148,13 +152,17 @@ function loadFavicon(iconElement) { | |
document.head.appendChild(newFavicon); | ||
} | ||
|
||
function initializeTwitchPlayer() { | ||
function initializeTwitchPlayer(retryCount = 3, delay = 1000) { | ||
try { | ||
var input = window.location.href.split('/'); | ||
var chnl = input[input.length - 1] || "uni1g"; | ||
|
||
document.title = chnl + " - YAUTC"; | ||
|
||
const twitchEmbed = document.getElementById('twitch-embed'); | ||
|
||
twitchEmbed.innerHTML = '' | ||
|
||
new Twitch.Player("twitch-embed", { | ||
width: "100%", | ||
height: "100%", | ||
|
@@ -166,7 +174,19 @@ function initializeTwitchPlayer() { | |
parent: ["fiszh.github.io"], | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
console.error("Error initializing Twitch Player:", error); | ||
|
||
const twitchEmbed = document.getElementById('twitch-embed'); | ||
|
||
twitchEmbed.innerHTML = "Refresh if you don't see the player." | ||
|
||
if (retryCount > 0) { | ||
setTimeout(() => { | ||
initializeTwitchPlayer(retryCount - 1, delay); | ||
}, delay); | ||
} else { | ||
console.error("Failed to initialize Twitch Player after multiple attempts."); | ||
} | ||
} | ||
} | ||
|
||
|