mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:32:45 +00:00 
			
		
		
		
	LibWeb: Allow seeking media elements with keyboard controls
This allows seeking backwards and forwards by 5 seconds with the left and right arrow keys, respectively. This also allows seeking to the beginning and end of the media track with the home and end keys.
This commit is contained in:
		
							parent
							
								
									a4070b1452
								
							
						
					
					
						commit
						6a5229c2cb
					
				
					 1 changed files with 21 additions and 0 deletions
				
			
		|  | @ -1864,6 +1864,27 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::handle_keydown(Badge<Web::EventHandl | |||
|         TRY(toggle_playback()); | ||||
|         break; | ||||
| 
 | ||||
|     case KeyCode::Key_Home: | ||||
|         set_current_time(0); | ||||
|         break; | ||||
|     case KeyCode::Key_End: | ||||
|         set_current_time(duration()); | ||||
|         break; | ||||
| 
 | ||||
|     case KeyCode::Key_Left: | ||||
|     case KeyCode::Key_Right: { | ||||
|         static constexpr double time_skipped_per_key_press = 5.0; | ||||
|         auto current_time = this->current_time(); | ||||
| 
 | ||||
|         if (key == KeyCode::Key_Left) | ||||
|             current_time = max(0.0, current_time - time_skipped_per_key_press); | ||||
|         else | ||||
|             current_time = min(duration(), current_time + time_skipped_per_key_press); | ||||
| 
 | ||||
|         set_current_time(current_time); | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     default: | ||||
|         break; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn