mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Explicitly detect mimetype support using test sounds.
This commit is contained in:
		| @@ -77,4 +77,13 @@ | |||||||
|         <url-pattern>/tunnel</url-pattern> |         <url-pattern>/tunnel</url-pattern> | ||||||
|     </servlet-mapping> |     </servlet-mapping> | ||||||
|  |  | ||||||
|  |     <mime-mapping> | ||||||
|  |         <extension>mp3</extension> | ||||||
|  |         <mime-type>audio/mpeg</mime-type> | ||||||
|  |     </mime-mapping> | ||||||
|  |     <mime-mapping> | ||||||
|  |         <extension>ogg</extension> | ||||||
|  |         <mime-type>audio/ogg</mime-type> | ||||||
|  |     </mime-mapping> | ||||||
|  |  | ||||||
| </web-app> | </web-app> | ||||||
|   | |||||||
| @@ -61,6 +61,9 @@ var GuacamoleUI = { | |||||||
|  |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | // Supported mimetypes | ||||||
|  | GuacamoleUI.supportedAudio = {}; | ||||||
|  |  | ||||||
| // Constant UI initialization and behavior | // Constant UI initialization and behavior | ||||||
| (function() { | (function() { | ||||||
|  |  | ||||||
| @@ -484,6 +487,33 @@ var GuacamoleUI = { | |||||||
|         GuacamoleUI.eventTarget.style.top = window.pageYOffset + "px"; |         GuacamoleUI.eventTarget.style.top = window.pageYOffset + "px"; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     function testAudio(url, mimetype) { | ||||||
|  |  | ||||||
|  |         // If browser says we can't play it, don't try | ||||||
|  |         var audio = new Audio(); | ||||||
|  |         if (!audio.canPlayType(mimetype)) | ||||||
|  |             return; | ||||||
|  |  | ||||||
|  |         // Otherwise, test | ||||||
|  |         audio.src = url; | ||||||
|  |  | ||||||
|  |         // On error, explicitly unsupported | ||||||
|  |         audio.addEventListener("error", function() { | ||||||
|  |             GuacamoleUI.supportedAudio[mimetype] = false; | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         // On successful play, explicitly supported | ||||||
|  |         audio.addEventListener("ended", function() { | ||||||
|  |             GuacamoleUI.supportedAudio[mimetype] = true; | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         audio.play(); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     testAudio("sounds/silence.mp3", "audio/mpeg"); | ||||||
|  |     testAudio("sounds/silence.ogg", "audio/ogg"); | ||||||
|  |  | ||||||
| })(); | })(); | ||||||
|  |  | ||||||
| // Tie UI events / behavior to a specific Guacamole client | // Tie UI events / behavior to a specific Guacamole client | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								guacamole/src/main/webapp/sounds/silence.mp3
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								guacamole/src/main/webapp/sounds/silence.mp3
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								guacamole/src/main/webapp/sounds/silence.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								guacamole/src/main/webapp/sounds/silence.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								guacamole/src/main/webapp/sounds/silence.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								guacamole/src/main/webapp/sounds/silence.wav
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user