Quellcode durchsuchen

LibWeb: Dispatch an addtrack event for newly created audio tracks

Timothy Flynn vor 2 Jahren
Ursprung
Commit
0c4b28faf3
1 geänderte Dateien mit 6 neuen und 1 gelöschten Zeilen
  1. 6 1
      Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp

+ 6 - 1
Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp

@@ -990,7 +990,12 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
         if (enable == TriState::True)
             audio_track->set_enabled(true);
 
-        // FIXME: 7. Fire an event named addtrack at this AudioTrackList object, using TrackEvent, with the track attribute initialized to the new AudioTrack object.
+        // 7. Fire an event named addtrack at this AudioTrackList object, using TrackEvent, with the track attribute initialized to the new AudioTrack object.
+        TrackEventInit event_init {};
+        event_init.track = JS::make_handle(audio_track);
+
+        auto event = TRY(TrackEvent::create(realm, HTML::EventNames::addtrack, move(event_init)));
+        m_audio_tracks->dispatch_event(event);
     }
 
     // -> If the media resource is found to have a video track