Skip to content

Commit 4e02245

Browse files
committed
Add integration test for MediaElementSourceNode
1 parent 892c8d4 commit 4e02245

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/media_element.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use web_audio_api::context::{AudioContext, AudioContextOptions, BaseAudioContext};
2+
use web_audio_api::node::AudioNode;
3+
use web_audio_api::MediaElement;
4+
5+
#[test]
6+
fn test_media_element_source_progress() {
7+
let options = AudioContextOptions {
8+
sink_id: "none".into(),
9+
..AudioContextOptions::default()
10+
};
11+
let context = AudioContext::new(options);
12+
13+
let mut media = MediaElement::new("samples/major-scale.ogg").unwrap();
14+
media.set_loop(true);
15+
16+
let src = context.create_media_element_source(&mut media);
17+
src.connect(&context.destination());
18+
media.play();
19+
20+
// sleep for a bit, make sure the audio thread has started
21+
std::thread::sleep(std::time::Duration::from_millis(100));
22+
23+
// assert the media has progressed
24+
assert!(media.current_time() > 0.05);
25+
}

0 commit comments

Comments
 (0)