-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add some hidden examples for debugging to the docs
- Loading branch information
Showing
5 changed files
with
66 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<DocsDemo as |demo|> | ||
<demo.example @name='queued.hbs'> | ||
|
||
{{#if (sound-is-playing (current-sound))}} | ||
<p>{{get (current-sound) 'url'}}</p> | ||
|
||
<button type='button' {{on 'click' (stop-sound (current-sound))}}> | ||
Stop | ||
</button> | ||
{{else}} | ||
<button type='button' {{on 'click' this.playSound}}> | ||
Play Queue | ||
</button> | ||
{{/if}} | ||
|
||
</demo.example> | ||
<demo.snippet @name='queued.hbs' /> | ||
<demo.snippet @name='queued.js' /> | ||
</DocsDemo> |
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,41 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
// BEGIN-SNIPPET queued.js | ||
export default class Queued extends Component { | ||
@service stereo; | ||
|
||
@tracked identifier; | ||
@tracked queue = []; | ||
|
||
@action | ||
async playSound() { | ||
this.queue = [ | ||
'/sounds/attention.mp3', | ||
'/sounds/internet-on-computers.mp3', | ||
'https://kut.streamguys1.com/kut-web.aac', | ||
]; | ||
|
||
let sound = await this.playNext(); | ||
sound.audioElement.setAttribute( | ||
'id', | ||
`id-${Math.floor(Math.random() * 10000)}` | ||
); | ||
|
||
this.stereo.on('audio-ended', ({ sound }) => { | ||
console.log(sound.audioElement); | ||
this.playNext(); | ||
}); | ||
} | ||
|
||
async playNext() { | ||
let next = this.queue.shift(); | ||
if (next) { | ||
let { sound } = await this.stereo.play(next); | ||
|
||
return sound; | ||
} | ||
} | ||
} | ||
// END-SNIPPET queued.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
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 |
---|---|---|
@@ -1,5 +1,2 @@ | ||
Modifiers to create position controls | ||
<Docs::CustomPositionControl @identifier="/sounds/works-just-like-a-vcr.mp3"/> | ||
|
||
Proxies | ||
<Docs::ProxyExample/> |
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,5 @@ | ||
Proxies | ||
<Docs::ProxyExample/> | ||
|
||
Queued | ||
<Docs::Queued/> |