Fetch language codes from gstreamer pipeline
This commit is contained in:
parent
17ce907f28
commit
1cb71331f7
2 changed files with 44 additions and 15 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
|
@ -853,9 +853,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.25"
|
||||
version = "1.1.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8d9e0b4957f635b8d3da819d0db5603620467ecf1f692d22a8c2717ce27e6d8"
|
||||
checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
|
@ -2739,7 +2739,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_video_player"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/jackpot51/iced_video_player.git?branch=cosmic#db329704ac04be7a7ca464d9687f66464118a371"
|
||||
source = "git+https://github.com/jackpot51/iced_video_player.git?branch=cosmic#52a3f4a96359716dfe74199ce46a24d3a376e6b1"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"gstreamer",
|
||||
|
|
@ -3783,12 +3783,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.1"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1"
|
||||
dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
|
|
@ -4091,12 +4088,6 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.20"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ use cosmic::{
|
|||
widget::{self, Column, Row, Slider},
|
||||
Application, ApplicationExt, Element,
|
||||
};
|
||||
use iced_video_player::{Video, VideoPlayer};
|
||||
use iced_video_player::{
|
||||
gst::{self, prelude::*},
|
||||
Video, VideoPlayer,
|
||||
};
|
||||
use std::{any::TypeId, collections::HashMap, time::Duration};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -149,6 +152,41 @@ impl Application for App {
|
|||
/// Creates the application, and optionally emits command on initialize.
|
||||
fn init(core: Core, flags: Self::Flags) -> (Self, Command<Self::Message>) {
|
||||
let video = Video::new(&flags.url).unwrap();
|
||||
let pipeline = video.pipeline();
|
||||
|
||||
let current_audio = pipeline.property::<i32>("current-audio");
|
||||
let n_audio = pipeline.property::<i32>("n-audio");
|
||||
let mut audio_codes = Vec::with_capacity(n_audio as usize);
|
||||
for i in 0..n_audio {
|
||||
let tags: gst::TagList = pipeline.emit_by_name("get-audio-tags", &[&i]);
|
||||
audio_codes.push(
|
||||
if let Some(language_code) = tags.get::<gst::tags::LanguageCode>() {
|
||||
language_code.get().to_string()
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
);
|
||||
}
|
||||
println!("audio language codes: {:#?}", audio_codes);
|
||||
|
||||
let current_text = pipeline.property::<i32>("current-text");
|
||||
let n_text = pipeline.property::<i32>("n-text");
|
||||
let mut text_codes = Vec::with_capacity(n_text as usize);
|
||||
for i in 0..n_text {
|
||||
let tags: gst::TagList = pipeline.emit_by_name("get-text-tags", &[&i]);
|
||||
text_codes.push(
|
||||
if let Some(language_code) = tags.get::<gst::tags::LanguageCode>() {
|
||||
language_code.get().to_string()
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
);
|
||||
}
|
||||
println!("text language codes: {:#?}", text_codes);
|
||||
|
||||
// Flags can be used to enable/disable subtitles
|
||||
println!("flags {:?}", pipeline.property_value("flags"));
|
||||
|
||||
let mut app = App {
|
||||
core,
|
||||
flags,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue