aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlmediaelement.rs
diff options
context:
space:
mode:
authorPhilippe Normand <philn@igalia.com>2017-11-21 14:23:32 +0000
committerPhilippe Normand <philn@igalia.com>2017-11-23 11:27:28 +0000
commit24454c33b2cc17ab7f540410ed6382d2d91688a4 (patch)
treef77c364e548a2666afff333d536596315f33839f /components/script/dom/htmlmediaelement.rs
parentca15c1000372b8cdec6000ef1a09fb5fa5985338 (diff)
downloadservo-24454c33b2cc17ab7f540410ed6382d2d91688a4.tar.gz
servo-24454c33b2cc17ab7f540410ed6382d2d91688a4.zip
Implement HTMLMediaElement::canPlayType using gecko-media
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r--components/script/dom/htmlmediaelement.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 1122e267e7e..a37a06d4047 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -31,10 +31,13 @@ use dom::node::{window_from_node, document_from_node, Node, UnbindContext};
use dom::promise::Promise;
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
+#[cfg(all(any(target_os = "macos", target_os = "linux"), not(any(target_arch = "arm", target_arch = "aarch64"))))]
+use gecko_media::{CanPlayType, GeckoMedia};
use html5ever::{LocalName, Prefix};
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use microtask::{Microtask, MicrotaskRunnable};
+#[allow(unused_imports)]
use mime::{Mime, SubLevel, TopLevel};
use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError};
use net_traits::request::{CredentialsMode, Destination, RequestInit};
@@ -869,6 +872,20 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-navigator-canplaytype
fn CanPlayType(&self, type_: DOMString) -> CanPlayTypeResult {
+ #[cfg(all(
+ any(target_os = "macos", target_os = "linux"),
+ not(any(target_arch = "arm", target_arch = "aarch64"))))]
+ {
+ let gecko_media = match GeckoMedia::get() {
+ Ok(gecko_media) => gecko_media,
+ Err(_error) => return CanPlayTypeResult::_empty,
+ };
+ return match gecko_media.can_play_type(&type_) {
+ CanPlayType::No => CanPlayTypeResult::_empty,
+ CanPlayType::Maybe => CanPlayTypeResult::Maybe,
+ CanPlayType::Probably => CanPlayTypeResult::Probably
+ };
+ }
match type_.parse::<Mime>() {
Ok(Mime(TopLevel::Application, SubLevel::OctetStream, _)) |
Err(_) => {