1use motion_canvas_rs::prelude::*;
2use std::time::Duration;
3
4fn main() {
5 let mut project = Project::default()
6 .with_dimensions(800, 450)
7 .with_title("Audio Demo")
8 .with_background(Color::rgb8(20, 20, 25))
9 .close_on_finish();
10
11 let rect = Rect::new(Vec2::new(100.0, 100.0), Vec2::new(200.0, 200.0), Color::RED)
13 .with_anchor(Vec2::new(-1.0, -1.0));
14
15 project.scene.add(Box::new(rect.clone()));
16
17 project.scene.video_timeline.add(chain!(
18 all![
19 rect.position
20 .to(Vec2::new(150.0, 150.0), Duration::from_secs(1)),
21 rect.size.to(Vec2::new(200.0, 50.0), Duration::from_secs(1)),
22 rect.fill_color.to(Color::BLUE, Duration::from_secs(1)),
23 ],
24 all![
25 rect.position
26 .to(Vec2::new(350.0, 150.0), Duration::from_secs(1)),
27 rect.fill_color.to(Color::RED, Duration::from_secs(1)),
28 ]
29 ));
30
31 project.scene.audio_timeline.add(chain!(
33 play!(AudioNode::new("./examples/audios/combo-1.mp3").with_volume(0.5)),
34 audio_wait!(0.05),
35 play!(AudioNode::new("./examples/audios/combo-2.mp3").with_volume(1.0))
36 ));
37
38 println!("Project configured with separate video and audio timelines.");
39 println!(
40 "Video duration: {:?}",
41 project.scene.video_timeline.duration()
42 );
43 println!(
44 "Audio duration: {:?}",
45 project.scene.audio_timeline.duration()
46 );
47
48 project.show().expect("Failed to run audio demo");
49}