mirror of
https://github.com/v0l/m3u8-rs.git
synced 2025-06-21 10:50:44 +00:00
Version 1.0.0
This commit is contained in:
19
examples/simple.rs
Normal file
19
examples/simple.rs
Normal file
@ -0,0 +1,19 @@
|
||||
extern crate nom;
|
||||
extern crate m3u8_rs;
|
||||
|
||||
use m3u8_rs::playlist::{Playlist};
|
||||
use std::io::Read;
|
||||
|
||||
fn main() {
|
||||
let mut file = std::fs::File::open("playlist.m3u8").unwrap();
|
||||
let mut bytes: Vec<u8> = Vec::new();
|
||||
file.read_to_end(&mut bytes).unwrap();
|
||||
|
||||
let parsed = m3u8_rs::parse_playlist_res(&bytes);
|
||||
|
||||
match parsed {
|
||||
Ok(Playlist::MasterPlaylist(pl)) => println!("Master playlist:\n{}", pl),
|
||||
Ok(Playlist::MediaPlaylist(pl)) => println!("Media playlist:\n{}", pl),
|
||||
Err(e) => println!("Error: {:?}", e)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user