Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pause audio? #4

Closed
antonkristiono opened this issue May 30, 2023 · 2 comments
Closed

How to pause audio? #4

antonkristiono opened this issue May 30, 2023 · 2 comments
Labels
good first issue Good for newcomers

Comments

@antonkristiono
Copy link

how to pause the audio

@Rajaniraiyn
Copy link
Owner

Thanks @antonkristiono to reaching out.
You can pause/stop the audio by adding another event listener as of v0.3.0

<script lang="ts">
  import { sound } from "svelte-sound";
  import click_mp3 from "/assets/click.mp3";

  let count: number = 0
  const increment = () => {
    count += 1
  }
</script>

<!-- below the sound starts when "mouseover" event is triggered and stops when "mouseleave" event is triggered -->
<button on:click={increment} use:sound={{src:click_mp3, events:["mouseover", "mouseleave"] }}> 
  count is {count}
</button>

So, basically you have to just add another event to the events array and it will be used to stop the sound playback.

Please check out v0.5.0's FAQ

@Rajaniraiyn Rajaniraiyn added the good first issue Good for newcomers label May 30, 2023
@Rajaniraiyn
Copy link
Owner

This issue has been fixed and there is no activity (response) from the reporter. so closing this issue

@Rajaniraiyn Rajaniraiyn pinned this issue Aug 6, 2023
@Rajaniraiyn Rajaniraiyn changed the title How to pause audio How to pause audio? Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants