-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Implement media element bindings
- Loading branch information
Showing
4 changed files
with
89 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/runtime/samples/binding-audio-currenttime-duration/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export default { | ||
// not sure if we can really test this in JSDOM. Refer to | ||
// https://svelte.technology/repl?example=media-elements | ||
// instead | ||
skip: true, | ||
|
||
test ( assert, component, target, window ) { | ||
assert.equal( component.get( 't' ), 0 ); | ||
assert.equal( component.get( 'd' ), 0 ); | ||
assert.equal( component.get( 'paused' ), true ); | ||
|
||
const audio = target.querySelector( 'audio' ); | ||
const timeupdate = new window.Event( 'timeupdate' ); | ||
const durationchange = new window.Event( 'durationchange' ); | ||
|
||
audio.currentTime = 10; | ||
audio.duration = 20; | ||
audio.dispatchEvent( timeupdate ); | ||
audio.dispatchEvent( durationchange ); | ||
audio.play(); | ||
|
||
assert.equal( component.get( 't' ), 10 ); | ||
assert.equal( component.get( 'd' ), 0 ); // not 20, because read-only. Not sure how to test this! | ||
assert.equal( component.get( 'paused' ), true ); // ditto... | ||
component.destroy(); | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
test/runtime/samples/binding-audio-currenttime-duration/main.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<audio bind:currentTime='t' bind:duration='d' bind:paused src='music.mp3'></audio> |