Struct script::dom::htmlmediaelement::HTMLMediaElement
source · #[repr(C)]pub struct HTMLMediaElement {Show 36 fields
htmlelement: HTMLElement,
network_state: Cell<NetworkState>,
ready_state: Cell<ReadyState>,
src_object: DomRefCell<Option<SrcObject>>,
current_src: DomRefCell<String>,
generation_id: Cell<u32>,
fired_loadeddata_event: Cell<bool>,
error: MutNullableDom<MediaError>,
paused: Cell<bool>,
defaultPlaybackRate: Cell<f64>,
playbackRate: Cell<f64>,
autoplaying: Cell<bool>,
delaying_the_load_event_flag: DomRefCell<Option<LoadBlocker>>,
pending_play_promises: DomRefCell<Vec<Rc<Promise>>>,
in_flight_play_promises_queue: DomRefCell<VecDeque<(Box<[Rc<Promise>]>, Result<(), Error>)>>,
player: DomRefCell<Option<Arc<Mutex<dyn Player>>>>,
video_renderer: Arc<Mutex<MediaFrameRenderer>>,
audio_renderer: DomRefCell<Option<Arc<Mutex<dyn AudioRenderer>>>>,
show_poster: Cell<bool>,
duration: Cell<f64>,
playback_position: Cell<f64>,
default_playback_start_position: Cell<f64>,
volume: Cell<f64>,
seeking: Cell<bool>,
muted: Cell<bool>,
resource_url: DomRefCell<Option<ServoUrl>>,
blob_url: DomRefCell<Option<ServoUrl>>,
played: DomRefCell<TimeRangesContainer>,
audio_tracks_list: MutNullableDom<AudioTrackList>,
video_tracks_list: MutNullableDom<VideoTrackList>,
text_tracks_list: MutNullableDom<TextTrackList>,
next_timeupdate_event: Cell<Instant>,
current_fetch_context: DomRefCell<Option<HTMLMediaElementFetchContext>>,
id: Cell<u64>,
media_controls_id: DomRefCell<Option<String>>,
player_context: WindowGLContext,
}
Fields§
§htmlelement: HTMLElement
§network_state: Cell<NetworkState>
§ready_state: Cell<ReadyState>
§src_object: DomRefCell<Option<SrcObject>>
§current_src: DomRefCell<String>
§generation_id: Cell<u32>
Incremented whenever tasks associated with this element are cancelled.
fired_loadeddata_event: Cell<bool>
https://html.spec.whatwg.org/multipage/#fire-loadeddata
Reset to false every time the load algorithm is invoked.
error: MutNullableDom<MediaError>
§paused: Cell<bool>
§defaultPlaybackRate: Cell<f64>
§playbackRate: Cell<f64>
§autoplaying: Cell<bool>
§delaying_the_load_event_flag: DomRefCell<Option<LoadBlocker>>
§pending_play_promises: DomRefCell<Vec<Rc<Promise>>>
§in_flight_play_promises_queue: DomRefCell<VecDeque<(Box<[Rc<Promise>]>, Result<(), Error>)>>
Play promises which are soon to be fulfilled by a queued task.
player: DomRefCell<Option<Arc<Mutex<dyn Player>>>>
§video_renderer: Arc<Mutex<MediaFrameRenderer>>
§audio_renderer: DomRefCell<Option<Arc<Mutex<dyn AudioRenderer>>>>
§show_poster: Cell<bool>
§duration: Cell<f64>
§playback_position: Cell<f64>
§default_playback_start_position: Cell<f64>
§volume: Cell<f64>
§seeking: Cell<bool>
§muted: Cell<bool>
§resource_url: DomRefCell<Option<ServoUrl>>
URL of the media resource, if any.
blob_url: DomRefCell<Option<ServoUrl>>
URL of the media resource, if the resource is set through the src_object attribute and it is a blob.
played: DomRefCell<TimeRangesContainer>
§audio_tracks_list: MutNullableDom<AudioTrackList>
§video_tracks_list: MutNullableDom<VideoTrackList>
§text_tracks_list: MutNullableDom<TextTrackList>
§next_timeupdate_event: Cell<Instant>
Time of last timeupdate notification.
current_fetch_context: DomRefCell<Option<HTMLMediaElementFetchContext>>
Latest fetch request context.
id: Cell<u64>
Player Id reported the player thread
media_controls_id: DomRefCell<Option<String>>
Media controls id. In order to workaround the lack of privileged JS context, we secure the the access to the “privileged” document.servoGetMediaControls(id) API by keeping a whitelist of media controls identifiers.
player_context: WindowGLContext
Implementations§
source§impl HTMLMediaElement
impl HTMLMediaElement
pub fn new_inherited( tag_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> Self
pub fn get_ready_state(&self) -> ReadyState
fn media_type_id(&self) -> HTMLMediaElementTypeId
fn play_media(&self)
sourcepub fn delay_load_event(&self, delay: bool, can_gc: CanGc)
pub fn delay_load_event(&self, delay: bool, can_gc: CanGc)
Marks that element as delaying the load event or not.
Nothing happens if the element was already delaying the load event and we pass true to that method again.
https://html.spec.whatwg.org/multipage/#delaying-the-load-event-flag
fn is_allowed_to_play(&self) -> bool
fn notify_about_playing(&self)
fn change_ready_state(&self, ready_state: ReadyState, can_gc: CanGc)
fn invoke_resource_selection_algorithm(&self, can_gc: CanGc)
fn resource_selection_algorithm_sync(&self, base_url: ServoUrl, can_gc: CanGc)
fn fetch_request( &self, offset: Option<u64>, seek_lock: Option<SeekLock>, can_gc: CanGc, )
fn resource_fetch_algorithm(&self, resource: Resource, can_gc: CanGc)
sourcefn queue_dedicated_media_source_failure_steps(&self, can_gc: CanGc)
fn queue_dedicated_media_source_failure_steps(&self, can_gc: CanGc)
Queues a task to run the dedicated media source failure steps.
fn queue_ratechange_event(&self)
fn in_error_state(&self) -> bool
fn is_potentially_playing(&self) -> bool
fn is_blocked_media_element(&self) -> bool
fn is_paused_for_user_interaction(&self) -> bool
fn is_paused_for_in_band_content(&self) -> bool
fn media_element_load_algorithm(&self, can_gc: CanGc)
sourcefn push_pending_play_promise(&self, promise: &Rc<Promise>)
fn push_pending_play_promise(&self, promise: &Rc<Promise>)
Appends a promise to the list of pending play promises.
sourcefn take_pending_play_promises(&self, result: Result<(), Error>)
fn take_pending_play_promises(&self, result: Result<(), Error>)
Takes the pending play promises.
The result with which these promises will be fulfilled is passed here
and this method returns nothing because we actually just move the
current list of pending play promises to the
in_flight_play_promises_queue
field.
Each call to this method must be followed by a call to
fulfill_in_flight_play_promises
, to actually fulfill the promises
which were taken and moved to the in-flight queue.
sourcefn fulfill_in_flight_play_promises<F>(&self, f: F)where
F: FnOnce(),
fn fulfill_in_flight_play_promises<F>(&self, f: F)where
F: FnOnce(),
Fulfills the next in-flight play promises queue after running a closure.
See the comment on take_pending_play_promises
for why this method
does not take a list of promises to fulfill. Callers cannot just pop
the front list off of in_flight_play_promises_queue
and later fulfill
the promises because that would mean putting
#[allow(crown::unrooted_must_root)]
on even more functions, potentially
hiding actual safety bugs.
sourcepub fn handle_source_child_insertion(&self, can_gc: CanGc)
pub fn handle_source_child_insertion(&self, can_gc: CanGc)
Handles insertion of source
children.
https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted
fn seek(&self, time: f64, _approximate_for_speed: bool)
fn seek_end(&self)
sourcepub fn process_poster_image_loaded(&self, image: Arc<Image>)
pub fn process_poster_image_loaded(&self, image: Arc<Image>)
fn setup_media_player( &self, resource: &Resource, can_gc: CanGc, ) -> Result<(), ()>
pub fn set_audio_track(&self, idx: usize, enabled: bool)
pub fn set_video_track(&self, idx: usize, enabled: bool)
fn handle_player_event(&self, event: &PlayerEvent, can_gc: CanGc)
fn earliest_possible_position(&self) -> f64
fn render_controls(&self)
fn remove_controls(&self)
pub fn get_current_frame(&self) -> Option<VideoFrame>
sourcepub fn set_audio_renderer(
&self,
audio_renderer: Arc<Mutex<dyn AudioRenderer>>,
can_gc: CanGc,
)
pub fn set_audio_renderer( &self, audio_renderer: Arc<Mutex<dyn AudioRenderer>>, can_gc: CanGc, )
By default the audio is rendered through the audio sink automatically selected by the servo-media Player instance. However, in some cases, like the WebAudio MediaElementAudioSourceNode, we need to set a custom audio renderer.
fn send_media_session_event(&self, event: MediaSessionEvent)
pub fn set_duration(&self, duration: f64)
sourcefn set_show_poster(&self, show_poster: bool)
fn set_show_poster(&self, show_poster: bool)
Sets a new value for the show_poster propperty. If the poster is being hidden because new frames should render, updates video_renderer to allow it.
pub fn reset(&self)
source§impl HTMLMediaElement
impl HTMLMediaElement
fn direction_of_playback(&self) -> PlaybackDirection
Trait Implementations§
source§impl Castable for HTMLMediaElement
impl Castable for HTMLMediaElement
source§impl DomObject for HTMLMediaElement
impl DomObject for HTMLMediaElement
source§impl Drop for HTMLMediaElement
impl Drop for HTMLMediaElement
source§impl HTMLMediaElementMethods for HTMLMediaElement
impl HTMLMediaElementMethods for HTMLMediaElement
fn NetworkState(&self) -> u16
fn ReadyState(&self) -> u16
fn Autoplay(&self) -> bool
fn SetAutoplay(&self, value: bool)
fn Loop(&self) -> bool
fn SetLoop(&self, value: bool)
fn DefaultMuted(&self) -> bool
fn SetDefaultMuted(&self, value: bool)
fn Controls(&self) -> bool
fn SetControls(&self, value: bool)
fn Src(&self) -> USVString
fn SetSrc(&self, value: USVString)
fn GetCrossOrigin(&self) -> Option<DOMString>
fn SetCrossOrigin(&self, value: Option<DOMString>)
fn Muted(&self) -> bool
fn SetMuted(&self, value: bool)
fn GetSrcObject(&self) -> Option<MediaStreamOrBlob>
fn SetSrcObject(&self, value: Option<MediaStreamOrBlob>, can_gc: CanGc)
fn Preload(&self) -> DOMString
fn SetPreload(&self, value: DOMString)
fn CurrentSrc(&self) -> USVString
fn Load(&self, can_gc: CanGc)
fn CanPlayType(&self, type_: DOMString) -> CanPlayTypeResult
fn GetError(&self) -> Option<Root<Dom<MediaError>>>
fn Play(&self, comp: InRealm<'_>, can_gc: CanGc) -> Rc<Promise>
fn Pause(&self, can_gc: CanGc)
fn Paused(&self) -> bool
fn Duration(&self) -> f64
fn CurrentTime(&self) -> Finite<f64>
fn SetCurrentTime(&self, time: Finite<f64>)
fn Seeking(&self) -> bool
fn Ended(&self) -> bool
fn FastSeek(&self, time: Finite<f64>)
fn Played(&self) -> Root<Dom<TimeRanges>>
fn Buffered(&self) -> Root<Dom<TimeRanges>>
fn AudioTracks(&self) -> Root<Dom<AudioTrackList>>
fn VideoTracks(&self) -> Root<Dom<VideoTrackList>>
fn TextTracks(&self) -> Root<Dom<TextTrackList>>
fn AddTextTrack( &self, kind: TextTrackKind, label: DOMString, language: DOMString, ) -> Root<Dom<TextTrack>>
fn GetVolume(&self) -> Result<Finite<f64>, Error>
fn SetVolume(&self, value: Finite<f64>) -> Result<(), Error>
source§impl HasParent for HTMLMediaElement
impl HasParent for HTMLMediaElement
source§fn as_parent(&self) -> &HTMLElement
fn as_parent(&self) -> &HTMLElement
This is used in a type assertion to ensure that the source and webidls agree as to what the parent type is
type Parent = HTMLElement
source§impl IDLInterface for HTMLMediaElement
impl IDLInterface for HTMLMediaElement
source§impl MallocSizeOf for HTMLMediaElement
impl MallocSizeOf for HTMLMediaElement
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl MutDomObject for HTMLMediaElement
impl MutDomObject for HTMLMediaElement
source§unsafe fn init_reflector(&self, obj: *mut JSObject)
unsafe fn init_reflector(&self, obj: *mut JSObject)
source§impl PartialEq for HTMLMediaElement
impl PartialEq for HTMLMediaElement
source§impl Traceable for HTMLMediaElement
impl Traceable for HTMLMediaElement
source§impl VirtualMethods for HTMLMediaElement
impl VirtualMethods for HTMLMediaElement
source§fn super_type(&self) -> Option<&dyn VirtualMethods>
fn super_type(&self) -> Option<&dyn VirtualMethods>
source§fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation<'_>)
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation<'_>)
source§fn unbind_from_tree(&self, context: &UnbindContext<'_>)
fn unbind_from_tree(&self, context: &UnbindContext<'_>)
source§fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool
fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool
true
if given attribute attr
affects style of the
given element.source§fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue
name
on this element.source§fn bind_to_tree(&self, context: &BindContext)
fn bind_to_tree(&self, context: &BindContext)
source§fn children_changed(&self, mutation: &ChildrenMutation<'_>)
fn children_changed(&self, mutation: &ChildrenMutation<'_>)
source§fn handle_event(&self, event: &Event)
fn handle_event(&self, event: &Event)
source§fn adopting_steps(&self, old_doc: &Document)
fn adopting_steps(&self, old_doc: &Document)
source§fn cloning_steps(
&self,
copy: &Node,
maybe_doc: Option<&Document>,
clone_children: CloneChildrenFlag,
)
fn cloning_steps( &self, copy: &Node, maybe_doc: Option<&Document>, clone_children: CloneChildrenFlag, )
impl DerivedFrom<Element> for HTMLMediaElement
impl DerivedFrom<EventTarget> for HTMLMediaElement
impl DerivedFrom<HTMLElement> for HTMLMediaElement
impl DerivedFrom<HTMLMediaElement> for HTMLAudioElement
impl DerivedFrom<HTMLMediaElement> for HTMLMediaElement
impl DerivedFrom<HTMLMediaElement> for HTMLVideoElement
impl DerivedFrom<Node> for HTMLMediaElement
impl Eq for HTMLMediaElement
Auto Trait Implementations§
impl !Freeze for HTMLMediaElement
impl !RefUnwindSafe for HTMLMediaElement
impl !Send for HTMLMediaElement
impl !Sync for HTMLMediaElement
impl Unpin for HTMLMediaElement
impl !UnwindSafe for HTMLMediaElement
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more