mirror of
				https://codeberg.org/ashley/poke
				synced 2025-07-17 16:52:11 +00:00 
			
		
		
		
	[IN TESTING] attempt to fix #106
This commit is contained in:
		
							parent
							
								
									769a6dea2d
								
							
						
					
					
						commit
						e71322bf0d
					
				| @ -984,44 +984,69 @@ function cstsRemaining(totalTimeInSeconds, elapsedTimeInSeconds) { | |||||||
|   }) |   }) | ||||||
| </script> | </script> | ||||||
| <script> | <script> | ||||||
| const audioContext = new (window.AudioContext || window.webkitAudioContext)(); | document.addEventListener("DOMContentLoaded", () => { | ||||||
| const source = audioContext.createMediaElementSource(aud); |     const audio = document.getElementById('aud'); | ||||||
| const analyser = audioContext.createAnalyser(); |  | ||||||
| 
 | 
 | ||||||
| source.connect(analyser); |     if (!video || !audio) { | ||||||
| analyser.connect(audioContext.destination); |         console.error("Video or audio element not found!"); | ||||||
| 
 |         return; | ||||||
| function getQueryParam(name) { |  | ||||||
|     const urlParams = new URLSearchParams(window.location.search); |  | ||||||
|     return urlParams.get(name); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // Check the quality parameter |  | ||||||
| const quality = getQueryParam('qua'); |  | ||||||
| 
 |  | ||||||
| // Function to check if audio is playing |  | ||||||
| function checkAudio() { |  | ||||||
|     if (video.ended || video.paused || quality === 'medium') return; |  | ||||||
| 
 |  | ||||||
|     // Check if the audio volume is greater than 0 |  | ||||||
|     if (aud.volume === 0) return; |  | ||||||
| 
 |  | ||||||
|     const bufferLength = analyser.fftSize; |  | ||||||
|     const dataArray = new Uint8Array(bufferLength); |  | ||||||
|     analyser.getByteFrequencyData(dataArray); |  | ||||||
|      |  | ||||||
|     // Check if there's any significant audio data |  | ||||||
|     const isAudioPlaying = dataArray.some(value => value > 0); |  | ||||||
| 
 |  | ||||||
|     if (!isAudioPlaying) { |  | ||||||
|         // Play/pause workaround to reset audio |  | ||||||
|         aud.pause(); |  | ||||||
|         aud.play(); |  | ||||||
|     } |     } | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| // Check audio every second |     // Checks if the browser supports AudioContext | ||||||
| setInterval(checkAudio, 1000); |     if (!window.AudioContext && !window.webkitAudioContext) { | ||||||
|  |         console.error("Web Audio API not supported in this browser."); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const audioContext = new (window.AudioContext || window.webkitAudioContext)(); | ||||||
|  |     let source; | ||||||
|  | 
 | ||||||
|  |     try { | ||||||
|  |         source = audioContext.createMediaElementSource(audio); | ||||||
|  |     } catch (e) { | ||||||
|  |         console.error("Error creating media element source:", e); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const analyser = audioContext.createAnalyser(); | ||||||
|  |     source.connect(analyser); | ||||||
|  |     analyser.connect(audioContext.destination); | ||||||
|  | 
 | ||||||
|  |     // Function to get query parameter from URL | ||||||
|  |     function getQueryParam(name) { | ||||||
|  |         const urlParams = new URLSearchParams(window.location.search); | ||||||
|  |         return urlParams.get(name); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Check the quality parameter | ||||||
|  |     const quality = getQueryParam('qua'); | ||||||
|  | 
 | ||||||
|  |     // Function to check if audio is playing | ||||||
|  |     function checkAudio() { | ||||||
|  |         // Check if the video has ended, is paused, or has medium quality | ||||||
|  |         if (video.ended || video.paused || quality === 'medium') return; | ||||||
|  | 
 | ||||||
|  |         // Check if the audio volume is greater than 0 | ||||||
|  |         if (audio.volume === 0) return; | ||||||
|  | 
 | ||||||
|  |         const bufferLength = analyser.fftSize; | ||||||
|  |         const dataArray = new Uint8Array(bufferLength); | ||||||
|  |         analyser.getByteFrequencyData(dataArray); | ||||||
|  | 
 | ||||||
|  |         // Check if there's any significant audio data | ||||||
|  |         const isAudioPlaying = dataArray.some(value => value > 0); | ||||||
|  | 
 | ||||||
|  |         if (!isAudioPlaying) { | ||||||
|  |             // Play/pause workaround to reset audio | ||||||
|  |             audio.pause(); | ||||||
|  |             audio.play(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Check audio every second | ||||||
|  |     setInterval(checkAudio, 1000); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| </script> | </script> | ||||||
|          <% if(shortsui) { %> |          <% if(shortsui) { %> | ||||||
|                                                        <script> |                                                        <script> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 ashley
						ashley