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

Play in vlc on mobile #443

Closed
wants to merge 7 commits into from
Closed
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
15 changes: 15 additions & 0 deletions src/deep_links/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ use percent_encoding::utf8_percent_encode;
use serde::Serialize;
use url::Url;

#[derive(Default, Serialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct VlcLink {
pub ios: String,
pub android: String,
}

#[derive(Default, Serialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ExternalPlayerLink {
pub href: Option<String>,
pub download: Option<String>,
pub streaming: Option<String>,
pub vlc: Option<VlcLink>,
pub android_tv: Option<String>,
pub tizen: Option<String>,
pub webos: Option<String>,
Expand All @@ -31,6 +39,12 @@ impl From<(&Stream, &Option<Url>)> for ExternalPlayerLink {
let m3u_uri = stream.m3u_data_uri(streaming_server_url.as_ref());
let file_name = m3u_uri.as_ref().map(|_| "playlist.m3u".to_owned());
let href = m3u_uri.or_else(|| download.to_owned());
let vlc = streaming.as_ref().map(|url| VlcLink {
ios: format!("vlc-x-callback://x-callback-url/stream?url={url}"),
android: format!(
"intent://{url}#Intent;package=org.videolan.vlc;type=video;scheme=https;end",
),
});
let (android_tv, tizen, webos) = match &stream.source {
StreamSource::External {
android_tv_url,
Expand All @@ -48,6 +62,7 @@ impl From<(&Stream, &Option<Url>)> for ExternalPlayerLink {
href,
download,
streaming,
vlc,
android_tv,
tizen,
webos,
Expand Down
12 changes: 11 additions & 1 deletion src/unit_tests/deep_links/video_deep_links.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::constants::BASE64;
use crate::deep_links::{ExternalPlayerLink, VideoDeepLinks};
use crate::deep_links::{ExternalPlayerLink, VideoDeepLinks, VlcLink};
use crate::types::addon::{ResourcePath, ResourceRequest};
use crate::types::resource::Video;
use base64::Engine;
Expand Down Expand Up @@ -52,6 +52,16 @@ fn video_deep_links() {
download: Some(format!("https://youtube.com/watch?v={}", YT_ID)),
streaming: Some(format!("{}yt/{}", STREAMING_SERVER_URL, YT_ID)),
file_name: Some("playlist.m3u".to_string()),
vlc: Some(VlcLink {
ios: format!(
"vlc-x-callback://x-callback-url/stream?url={}yt/{}",
STREAMING_SERVER_URL, YT_ID,
),
android: format!(
"intent://{}yt/{}#Intent;package=org.videolan.vlc;type=video;scheme=https;end",
STREAMING_SERVER_URL, YT_ID,
),
}),
..Default::default()
})
);
Expand Down