diff options
Diffstat (limited to 'server/src/routes/ui')
-rw-r--r-- | server/src/routes/ui/player.rs | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs index c2188a8..d2a8236 100644 --- a/server/src/routes/ui/player.rs +++ b/server/src/routes/ui/player.rs @@ -6,22 +6,20 @@ use super::{ account::session::{token, Session}, layout::LayoutPage, - node::{get_similar_media, DatabaseNodeUserDataExt, NodePage}, - sort::NodeFilterSort, + node::{get_similar_media, DatabaseNodeUserDataExt}, }; use crate::{ database::Database, - routes::{ - stream::rocket_uri_macro_r_stream, - ui::{error::MyResult, layout::DynLayoutPage}, + routes::ui::{ + assets::rocket_uri_macro_r_item_backdrop, error::MyResult, layout::DynLayoutPage, }, uri, }; use anyhow::anyhow; -use jellybase::{permission::PermissionSetExt, CONF}; +use jellybase::CONF; use jellycommon::{ - stream::{StreamFormat, StreamSpec}, - user::{PermissionSet, PlayerKind, UserPermission}, + stream::{StreamContainer, StreamSpec}, + user::{PermissionSet, PlayerKind}, Node, NodeID, SourceTrackKind, TrackID, Visibility, }; use markup::DynRender; @@ -49,13 +47,14 @@ impl PlayerConfig { fn jellynative_url(action: &str, seek: f64, secret: &str, node: &str, session: &str) -> String { let protocol = if CONF.tls { "https" } else { "http" }; let host = &CONF.hostname; - let stream_url = uri!(r_stream( - node, - StreamSpec { - format: StreamFormat::HlsMaster, - ..Default::default() + let stream_url = format!( + "/n/{node}/stream{}", + StreamSpec::HlsMultiVariant { + segment: 0, + container: StreamContainer::Matroska } - )); + .to_query() + ); format!("jellynative://{action}/{secret}/{session}/{seek}/{protocol}://{host}{stream_url}",) } @@ -66,7 +65,7 @@ pub fn r_player( id: NodeID, conf: PlayerConfig, ) -> MyResult<Either<DynLayoutPage<'_>, Redirect>> { - let (node, udata) = db.get_node_with_userdata(id, &session)?; + let (node, _udata) = db.get_node_with_userdata(id, &session)?; let mut parents = node .parents @@ -80,14 +79,6 @@ pub fn r_player( parents.retain(|(n, _)| n.visibility >= Visibility::Reduced); let native_session = |action: &str| { - let perm = [ - UserPermission::StreamFormat(StreamFormat::HlsMaster), - UserPermission::StreamFormat(StreamFormat::HlsVariant), - UserPermission::StreamFormat(StreamFormat::Fragment), - ]; - for perm in &perm { - session.user.permissions.assert(perm)?; - } Ok(Either::Right(Redirect::temporary(jellynative_url( action, conf.t.unwrap_or(0.), @@ -95,7 +86,7 @@ pub fn r_player( &id.to_string(), &token::create( session.user.name, - PermissionSet(perm.map(|e| (e, true)).into()), + PermissionSet::default(), // TODO chrono::Duration::hours(24), ), )))) @@ -111,27 +102,32 @@ pub fn r_player( } } - let spec = StreamSpec { - track: None - .into_iter() - .chain(conf.v) - .chain(conf.a) - .chain(conf.s) - .collect::<Vec<_>>(), - format: StreamFormat::Matroska, - webm: Some(true), - ..Default::default() - }; + // TODO + // let spec = StreamSpec { + // track: None + // .into_iter() + // .chain(conf.v) + // .chain(conf.a) + // .chain(conf.s) + // .collect::<Vec<_>>(), + // format: StreamFormat::Matroska, + // webm: Some(true), + // ..Default::default() + // }; - let playing = !spec.track.is_empty(); + let playing = false; // !spec.track.is_empty(); let conf = player_conf(node.clone(), playing)?; Ok(Either::Left(LayoutPage { title: node.title.to_owned().unwrap_or_default(), class: Some("player"), content: markup::new! { - video[id="player", src=uri!(r_stream(&node.slug, &spec)), controls, preload="auto"]{} - @NodePage { children: &[], parents: &parents, filter: &NodeFilterSort::default(), node: &node, udata: &udata, player: true, similar: &similar } + @if playing { + // TODO + // video[src=uri!(r_stream(&node.slug, &spec)), controls, preload="auto"]{} + } else { + img.backdrop[src=uri!(r_item_backdrop(&node.slug, Some(2048))).to_string()]; + } @conf }, })) |