diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/Cargo.toml | 4 | ||||
-rw-r--r-- | components/script/dom/htmlmediaelement.rs | 48 | ||||
-rw-r--r-- | components/script/lib.rs | 1 |
3 files changed, 34 insertions, 19 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 96d81f76366..2847a39a180 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -17,6 +17,9 @@ debugmozjs = ['js/debugmozjs'] [target.'cfg(any(target_os = "macos", target_os = "linux"))'.dependencies] tinyfiledialogs = {git = "https://github.com/jdm/tinyfiledialogs"} +[target.'cfg(not(target_os = "android"))'.dependencies] +video-metadata = {git = "https://github.com/GuillaumeGomez/video-metadata-rs"} + [dependencies] angle = {git = "https://github.com/servo/angle", branch = "servo"} app_units = "0.2.5" @@ -67,7 +70,6 @@ time = "0.1.12" url = {version = "1.0.0", features = ["heap_size", "query_encoding"]} util = {path = "../util"} uuid = {version = "0.2", features = ["v4"]} -video-metadata = {git = "https://github.com/GuillaumeGomez/video-metadata-rs"} websocket = "0.17" xml5ever = {version = "0.1.2", features = ["unstable"]} diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index cc8bed31ebd..d3a0562173f 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -89,24 +89,7 @@ impl AsyncResponseListener for HTMLMediaElementContext { // https://html.spec.whatwg.org/multipage/#media-data-processing-steps-list // => "Once enough of the media data has been fetched to determine the duration..." if !self.have_metadata { - match video_metadata::get_format_from_slice(&self.data) { - Ok(meta) => { - let dur = meta.duration.unwrap_or(::std::time::Duration::new(0, 0)); - *elem.video.borrow_mut() = Some(VideoMedia { - format: format!("{:?}", meta.format), - duration: Duration::seconds(dur.as_secs() as i64) + - Duration::nanoseconds(dur.subsec_nanos() as i64), - width: meta.size.width, - height: meta.size.height, - video: meta.video, - audio: meta.audio, - }); - // Step 6 - elem.change_ready_state(HAVE_METADATA); - self.have_metadata = true; - } - _ => {} - } + self.check_metadata(&elem); } else { elem.change_ready_state(HAVE_CURRENT_DATA); } @@ -176,6 +159,35 @@ impl HTMLMediaElementContext { ignore_response: false, } } + + #[cfg(not(target_os = "android"))] + fn check_metadata(&mut self, elem: &HTMLMediaElement) { + match video_metadata::get_format_from_slice(&self.data) { + Ok(meta) => { + let dur = meta.duration.unwrap_or(::std::time::Duration::new(0, 0)); + *elem.video.borrow_mut() = Some(VideoMedia { + format: format!("{:?}", meta.format), + duration: Duration::seconds(dur.as_secs() as i64) + + Duration::nanoseconds(dur.subsec_nanos() as i64), + width: meta.size.width, + height: meta.size.height, + video: meta.video, + audio: meta.audio, + }); + // Step 6 + elem.change_ready_state(HAVE_METADATA); + self.have_metadata = true; + } + _ => {} + } + } + + #[cfg(target_os = "android")] + fn check_metadata(&mut self, _elem: &HTMLMediaElement) { + // Step 6. + elem.change_ready_state(HAVE_METADATA); + self.have_metadata = true; + } } #[derive(JSTraceable, HeapSizeOf)] diff --git a/components/script/lib.rs b/components/script/lib.rs index 0b0a45f701c..792aa24b438 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -88,6 +88,7 @@ extern crate url; #[macro_use] extern crate util; extern crate uuid; +#[cfg(not(target_os = "android"))] extern crate video_metadata; extern crate webrender_traits; extern crate websocket; |