rsmediainfo 0.2.0

Rust wrapper for MediaInfo library
//! Example that constructs a `MediaInfo` directly from a pre-generated XML
//! string.
//!
//! This entrypoint never touches the underlying media library, so it works
//! in offline environments or in tests where pulling the shared library
//! into the process is not desirable. The XML payload here is hand-written
//! for clarity but the same constructor accepts any document the library
//! itself would emit through its `OLDXML` output mode.
//!
//! Run with:
//!
//! ```text
//! cargo run --example parse_xml
//! ```

use rsmediainfo::MediaInfo;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let xml = r#"<?xml version="1.0"?>
<File>
<track type="General">
<Format>Matroska</Format>
<Duration>3000</Duration>
</track>
<track type="Video">
<Format>AVC</Format>
<Width>1920</Width>
<Height>1080</Height>
</track>
</File>"#;

    let mi = MediaInfo::from_xml(xml)?;

    println!("Parsed {} tracks from XML", mi.tracks().len());
    for track in mi.tracks() {
        println!("  {} track:", track.track_type());
        for (key, value) in track.attributes() {
            println!("    {key} = {value:?}");
        }
    }

    Ok(())
}