mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Set media stream as seekable only if the server supports range requests
This commit is contained in:
parent
5112e0435c
commit
c8806767a0
1 changed files with 19 additions and 7 deletions
|
@ -710,13 +710,6 @@ impl HTMLMediaElement {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX(ferjm) Since we only support Blob for now it is fine to always set
|
|
||||||
// the stream type to StreamType::Seekable. Once we support MediaStream,
|
|
||||||
// this should be changed to also consider StreamType::Stream.
|
|
||||||
if let Err(e) = self.player.set_stream_type(StreamType::Seekable) {
|
|
||||||
eprintln!("Could not set stream type to Seekable. {:?}", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Steps 1-2.
|
// Steps 1-2.
|
||||||
// Unapplicable, the `resource` variable already conveys which mode
|
// Unapplicable, the `resource` variable already conveys which mode
|
||||||
// is in use.
|
// is in use.
|
||||||
|
@ -729,6 +722,20 @@ impl HTMLMediaElement {
|
||||||
Resource::Url(url) => {
|
Resource::Url(url) => {
|
||||||
// Step 4.remote.1.
|
// Step 4.remote.1.
|
||||||
if self.Preload() == "none" && !self.autoplaying.get() {
|
if self.Preload() == "none" && !self.autoplaying.get() {
|
||||||
|
// We only set the stream type to Seekable in two cases:
|
||||||
|
//
|
||||||
|
// - If the url is a file:// url. Our network stack supports range requests for
|
||||||
|
// file:// urls.
|
||||||
|
// - If the url is an http(s):// url and we identify that the server supports
|
||||||
|
// range requests.
|
||||||
|
//
|
||||||
|
// In the remaining cases, we use the default Stream type.
|
||||||
|
if url.scheme() == "file" {
|
||||||
|
if let Err(e) = self.player.set_stream_type(StreamType::Seekable) {
|
||||||
|
warn!("Could not set stream type to Seekable. {:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Step 4.remote.1.1.
|
// Step 4.remote.1.1.
|
||||||
self.network_state.set(NetworkState::Idle);
|
self.network_state.set(NetworkState::Idle);
|
||||||
|
|
||||||
|
@ -1691,6 +1698,11 @@ impl FetchResponseListener for HTMLMediaElementContext {
|
||||||
// header. Otherwise, we get it from the Content-Length header.
|
// header. Otherwise, we get it from the Content-Length header.
|
||||||
let content_length =
|
let content_length =
|
||||||
if let Some(content_range) = headers.typed_get::<ContentRange>() {
|
if let Some(content_range) = headers.typed_get::<ContentRange>() {
|
||||||
|
// The server supports range requests, so we can safely set the
|
||||||
|
// type of stream to Seekable.
|
||||||
|
if let Err(e) = elem.player.set_stream_type(StreamType::Seekable) {
|
||||||
|
warn!("Could not set stream type to Seekable. {:?}", e);
|
||||||
|
}
|
||||||
content_range.bytes_len()
|
content_range.bytes_len()
|
||||||
} else if let Some(content_length) = headers.typed_get::<ContentLength>() {
|
} else if let Some(content_length) = headers.typed_get::<ContentLength>() {
|
||||||
Some(content_length.0)
|
Some(content_length.0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue