File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments