Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/stream rar and zip stream creation #665

Draft
wants to merge 5 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/deep_links/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,34 @@ impl From<(&Stream, Option<&Url>, &Settings)> for ExternalPlayerLink {
"choose" => Some(OpenPlayerLink {
android: Some(format!(
"{}#Intent;type=video/any;scheme=https;end",
http_regex.replace(url, "intent://"),
http_regex.replace(url.as_str(), "intent://"),
)),
..Default::default()
}),
"vlc" => Some(OpenPlayerLink {
ios: Some(format!("vlc-x-callback://x-callback-url/stream?url={url}")),
android: Some(format!(
"{}#Intent;package=org.videolan.vlc;type=video;scheme=https;end",
http_regex.replace(url, "intent://"),
http_regex.replace(url.as_str(), "intent://"),
)),
..Default::default()
}),
"mxplayer" => Some(OpenPlayerLink {
android: Some(format!(
"{}#Intent;package=com.mxtech.videoplayer.ad;type=video;scheme=https;end",
http_regex.replace(url, "intent://"),
http_regex.replace(url.as_str(), "intent://"),
)),
..Default::default()
}),
"justplayer" => Some(OpenPlayerLink {
android: Some(format!(
"{}#Intent;package=com.brouken.player;type=video;scheme=https;end",
http_regex.replace(url, "intent://"),
http_regex.replace(url.as_str(), "intent://"),
)),
..Default::default()
}),
"outplayer" => Some(OpenPlayerLink {
ios: Some(format!("{}", http_regex.replace(url, "outplayer://"))),
ios: Some(format!("{}", http_regex.replace(url.as_str(), "outplayer://"))),
..Default::default()
}),
"infuse" => Some(OpenPlayerLink {
Expand Down Expand Up @@ -157,7 +157,7 @@ impl From<(&Stream, Option<&Url>, &Settings)> for ExternalPlayerLink {
};
ExternalPlayerLink {
download,
streaming,
streaming: streaming.as_ref().map(ToString::to_string),
playlist,
file_name,
open_player,
Expand Down
57 changes: 55 additions & 2 deletions src/models/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::models::common::{
};
use crate::models::ctx::{Ctx, CtxError};
use crate::runtime::msg::{Action, ActionLoad, ActionPlayer, Event, Internal, Msg};
use crate::runtime::{Effect, EffectFuture, Effects, Env, EnvFutureExt, UpdateWithCtx};
use crate::runtime::{Effect, EffectFuture, Effects, Env, EnvError, EnvFutureExt, UpdateWithCtx};
use crate::types::addon::{AggrRequest, Descriptor, ExtraExt, ResourcePath, ResourceRequest};
use crate::types::api::{
fetch_api, APIRequest, APIResult, SeekLog, SeekLogRequest, SkipGapsRequest, SkipGapsResponse,
Expand All @@ -26,7 +26,9 @@ use crate::types::api::{
use crate::types::library::{LibraryBucket, LibraryItem};
use crate::types::player::{IntroData, IntroOutro};
use crate::types::profile::{Profile, Settings as ProfileSettings};
use crate::types::resource::{MetaItem, SeriesInfo, Stream, StreamSource, Subtitles, Video};
use crate::types::resource::{
MetaItem, SeriesInfo, Stream, StreamSource, StreamUrls, Subtitles, Video,
};
use crate::types::streams::{StreamItemState, StreamsBucket, StreamsItemKey};

use stremio_watched_bitfield::WatchedBitField;
Expand Down Expand Up @@ -96,6 +98,7 @@ pub struct Player {
pub next_video: Option<Video>,
pub next_streams: Option<ResourceLoadable<Vec<Stream>>>,
pub next_stream: Option<Stream>,
pub stream_urls: Loadable<StreamUrls, EnvError>,
pub series_info: Option<SeriesInfo>,
pub library_item: Option<LibraryItem>,
pub stream_state: Option<StreamItemState>,
Expand Down Expand Up @@ -168,6 +171,13 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
};
let stream_state_effects = eq_update(&mut self.stream_state, None);
let video_params_effects = eq_update(&mut self.video_params, None);

let stream_urls_effects = eq_update(&mut self.stream_urls, Loadable::Loading);
let update_stream_source_effects =
Effects::msg(Msg::Internal(Internal::UpdateStreamSource {
stream: selected.stream.to_owned(),
}));

let subtitles_effects = subtitles_update::<E>(
&mut self.subtitles,
&self.selected,
Expand Down Expand Up @@ -268,6 +278,8 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
.join(meta_item_effects)
.join(stream_state_effects)
.join(video_params_effects)
.join(stream_urls_effects)
.join(update_stream_source_effects)
.join(subtitles_effects)
.join(next_video_effects)
.join(next_streams_effects)
Expand Down Expand Up @@ -539,6 +551,22 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
.map(|library_item| library_item.state.time_offset),
);

let item_state_update_effects = item_state_update(&mut self.library_item, &self.next_video);
// let item_state_update_effects = if self
// .selected
// .as_ref()
// .and_then(|selected| selected.meta_request.as_ref())
// .map(|meta_request| &meta_request.path.id)
// != self.selected
// .meta_request
// .as_ref()
// .map(|meta_request| &meta_request.path.id)
// {
// item_state_update(&mut self.library_item, &self.next_video)
// } else {
// Effects::none().unchanged()
// };

// Set time_offset to 0 as we switch to next video
let library_item_effects = self
.library_item
Expand All @@ -551,6 +579,7 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {

// Load will actually take care of loading the next video
seek_history_effects
.join(item_state_update_effects)
.join(
Effects::msg(Msg::Event(Event::PlayerNextVideo {
context: self.analytics_context.as_ref().cloned().unwrap_or_default(),
Expand Down Expand Up @@ -722,6 +751,30 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
};
Effects::none().unchanged()
}
Msg::Internal(Internal::StreamingServerStreamSourceResult {
original,
result,
streaming_server_url,
}) => {
let next_stream_url_effects = match &self.selected {
// update it only if the result is for the same original
// stream that the request was made for
Some(selected) if &selected.stream == original => {
let next_stream_url = match result {
Ok(stream) => Loadable::Ready(StreamUrls::new(
stream,
streaming_server_url.as_ref(),
)),
Err(err) => Loadable::Err(err.to_owned()),
};

eq_update(&mut self.stream_urls, next_stream_url)
}
_ => Effects::none().unchanged(),
};

next_stream_url_effects
}
_ => Effects::none().unchanged(),
}
}
Expand Down
Loading
Loading