Linux: render video via HTML5 WebView instead of the MPV backend
- online.rs: on Linux, advertise only WebView-decodable codecs (h264 video; aac/mp3/opus/vorbis/flac audio) in PlaybackInfo so Jellyfin transcodes HEVC/AV1/VP9/etc. to h264 HLS for the WebKitGTK <video> element. - player: on Linux, don't load video into MPV (no embedded window — it would start a redundant decode the frontend immediately stops). Add PlayerController::set_current_item to keep queue/UI/remote-transfer state in sync without loading the item into the playback backend.
This commit is contained in:
parent
ea342d76e3
commit
6146d70bc5
@ -411,9 +411,22 @@ pub async fn player_play_item(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let controller = player.0.lock().await;
|
let controller = player.0.lock().await;
|
||||||
|
// On Linux, video plays in the WebKitGTK HTML5 <video> element (see
|
||||||
|
// get_player_status -> use_html5_element). The MPV backend has no embedded
|
||||||
|
// window, so loading the stream into it would only start a redundant decode
|
||||||
|
// (and the frontend would immediately stop it). Only load into the native
|
||||||
|
// backend on platforms that actually render video through it (e.g. Android).
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
controller
|
controller
|
||||||
.play_item(media_item)
|
.play_item(media_item)
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
// Keep the queue in sync for UI/remote-transfer without starting MPV.
|
||||||
|
controller
|
||||||
|
.set_current_item(media_item)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
}
|
||||||
|
|
||||||
// Emit queue changed event
|
// Emit queue changed event
|
||||||
controller.emit_queue_changed();
|
controller.emit_queue_changed();
|
||||||
|
|||||||
@ -212,6 +212,22 @@ impl PlayerController {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the current queue item without loading it into the playback backend.
|
||||||
|
///
|
||||||
|
/// Used on platforms where video is rendered outside the native backend
|
||||||
|
/// (Linux WebKitGTK HTML5 <video>): the queue/UI state must reflect the
|
||||||
|
/// item, but MPV must not start a redundant decode for it.
|
||||||
|
pub fn set_current_item(&self, item: MediaItem) -> Result<(), PlayerError> {
|
||||||
|
debug!("[PlayerController] set_current_item (no backend load): {}", item.title);
|
||||||
|
|
||||||
|
self.reset_autoplay_count();
|
||||||
|
|
||||||
|
let mut queue = self.queue.lock_safe();
|
||||||
|
queue.set_queue(vec![item], 0);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Load and play an item without modifying the queue
|
/// Load and play an item without modifying the queue
|
||||||
/// Use this when the queue is already set up and you just want to play a specific item from it
|
/// Use this when the queue is already set up and you just want to play a specific item from it
|
||||||
pub fn load_and_play(&self, item: &MediaItem) -> Result<(), PlayerError> {
|
pub fn load_and_play(&self, item: &MediaItem) -> Result<(), PlayerError> {
|
||||||
|
|||||||
@ -859,7 +859,18 @@ impl MediaRepository for OnlineRepository {
|
|||||||
("h264,hevc".to_string(), "aac,mp3".to_string())
|
("h264,hevc".to_string(), "aac,mp3".to_string())
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(not(target_os = "android"))]
|
// Linux desktop plays video through the WebKitGTK HTML5 <video> element,
|
||||||
|
// which cannot reliably decode HEVC/AV1/VP9. Advertise only codecs the
|
||||||
|
// WebView can decode so Jellyfin transcodes anything else to h264 HLS.
|
||||||
|
// (Audio-only files still direct-play via MPV, but the PlaybackInfo
|
||||||
|
// profile is shared, so we keep the broadly-supported audio codecs.)
|
||||||
|
#[cfg(all(not(target_os = "android"), target_os = "linux"))]
|
||||||
|
let (video_codecs, audio_codecs) = (
|
||||||
|
"h264".to_string(),
|
||||||
|
"aac,mp3,opus,vorbis,flac".to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(all(not(target_os = "android"), not(target_os = "linux")))]
|
||||||
let (video_codecs, audio_codecs) = (
|
let (video_codecs, audio_codecs) = (
|
||||||
"h264,hevc,vp8,vp9,av1,mpeg4".to_string(),
|
"h264,hevc,vp8,vp9,av1,mpeg4".to_string(),
|
||||||
"aac,mp3,opus,vorbis,flac".to_string(),
|
"aac,mp3,opus,vorbis,flac".to_string(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user