Skip to content

Commit

Permalink
core: Use root movie URL as base for relative NetStream URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
n0samu authored and torokati44 committed Aug 11, 2023
1 parent fb01473 commit 0b368f1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::cmp::max;
use std::io::Seek;
use std::sync::{Arc, Mutex};
use swf::{VideoCodec, VideoDeblocking};
use url::Url;

/// Manager for all media streams.
///
Expand Down Expand Up @@ -258,7 +259,13 @@ impl<'gc> NetStream<'gc> {
/// available in the buffer.
pub fn play(self, context: &mut UpdateContext<'_, 'gc>, name: Option<AvmString<'gc>>) {
if let Some(name) = name {
let request = Request::get(name.to_string());
let request = if let Ok(stream_url) =
Url::parse(context.swf.url()).and_then(|url| url.join(name.to_string().as_str()))
{
Request::get(stream_url.to_string())
} else {
Request::get(name.to_string())
};
let mut write = self.0.write(context.gc_context);
write.url = Some(request.url().to_string());
write.preload_offset = 0;
Expand Down

0 comments on commit 0b368f1

Please sign in to comment.