mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Add MediaStream.getTrackById()
This commit is contained in:
parent
70e1c29ae9
commit
571c3d6d0e
2 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,7 @@ use crate::dom::bindings::cell::DomRefCell;
|
|||
use crate::dom::bindings::codegen::Bindings::MediaStreamBinding::{self, MediaStreamMethods};
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::mediastreamtrack::MediaStreamTrack;
|
||||
|
@ -73,4 +74,13 @@ impl MediaStreamMethods for MediaStream {
|
|||
.map(|x| DomRoot::from_ref(&**x))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// https://w3c.github.io/mediacapture-main/#dom-mediastream-gettrackbyid
|
||||
fn GetTrackById(&self, id: DOMString) -> Option<DomRoot<MediaStreamTrack>> {
|
||||
self.tracks
|
||||
.borrow()
|
||||
.iter()
|
||||
.find(|x| x.id().id().to_string() == &*id)
|
||||
.map(|x| DomRoot::from_ref(&**x))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue