Skip to content

Commit

Permalink
Loop (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH authored May 18, 2021
1 parent 395848f commit 3ac027f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>0.9.6-preview-01</VersionPrefix>
<VersionPrefix>0.9.6</VersionPrefix>
</PropertyGroup>

<Choose>
Expand Down
18 changes: 18 additions & 0 deletions examples/Howler.Blazor-AudioPlayer/Pages/Example.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<td><button class="btn btn-primary oi oi-media-play" @onclick="Play3"></button></td>
<td>Play an audio file with source location and format</td>
</tr>
<tr>
<td><button class="btn btn-primary oi oi-media-play" @onclick="PlayLoop"></button></td>
<td>Play and loop an audio file</td>
</tr>
<tr>
<td><button class="btn btn-primary oi oi-media-pause" @onclick="Pause"></button></td>
<td>Pause</td>
Expand Down Expand Up @@ -152,6 +156,20 @@
SoundIds.Add(await Howl.Play(options));
}

protected async Task PlayLoop()
{
ErrorMessage = string.Empty;
Rate = 1.0;

var options = new HowlOptions
{
Sources = new[] { "https://stefsapublic.blob.core.windows.net/test/ding.mp3" },
Loop = true
};

SoundIds.Add(await Howl.Play(options));
}

protected async Task Stop()
{
foreach (int id in SoundIds)
Expand Down
18 changes: 18 additions & 0 deletions examples/Howler.Blazor-WASM-AudioPlayer-NET5/Pages/Example.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<td><button class="btn btn-primary oi oi-media-play" @onclick="Play3"></button></td>
<td>Play an audio file with source location and format</td>
</tr>
<tr>
<td><button class="btn btn-primary oi oi-media-play" @onclick="PlayLoop"></button></td>
<td>Play and loop an audio file</td>
</tr>
<tr>
<td><button class="btn btn-primary oi oi-media-pause" @onclick="Pause"></button></td>
<td>Pause</td>
Expand Down Expand Up @@ -152,6 +156,20 @@
SoundIds.Add(await Howl.Play(options));
}

protected async Task PlayLoop()
{
ErrorMessage = string.Empty;
Rate = 1.0;

var options = new HowlOptions
{
Sources = new[] { "https://stefsapublic.blob.core.windows.net/test/ding.mp3" },
Loop = true
};

SoundIds.Add(await Howl.Play(options));
}

protected async Task Stop()
{
foreach (int id in SoundIds)
Expand Down
18 changes: 18 additions & 0 deletions examples/Howler.Blazor-WASM-AudioPlayer/Pages/Example.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<td><button class="btn btn-primary oi oi-media-play" @onclick="Play3"></button></td>
<td>Play an audio file with source location and format</td>
</tr>
<tr>
<td><button class="btn btn-primary oi oi-media-play" @onclick="PlayLoop"></button></td>
<td>Play and loop an audio file</td>
</tr>
<tr>
<td><button class="btn btn-primary oi oi-media-pause" @onclick="Pause"></button></td>
<td>Pause</td>
Expand Down Expand Up @@ -152,6 +156,20 @@
SoundIds.Add(await Howl.Play(options));
}

protected async Task PlayLoop()
{
ErrorMessage = string.Empty;
Rate = 1.0;

var options = new HowlOptions
{
Sources = new[] { "https://stefsapublic.blob.core.windows.net/test/ding.mp3" },
Loop = true
};

SoundIds.Add(await Howl.Play(options));
}

protected async Task Stop()
{
foreach (int id in SoundIds)
Expand Down
7 changes: 6 additions & 1 deletion src/Howler.Blazor/Components/HowlOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public class HowlOptions
/// Set to true to force HTML5 Audio.
/// This should be used for large audio files so that you don't have to wait for the full file to be downloaded and decoded before playing.
/// </summary>
public bool Html5 { get; set; }
public bool Html5 { get; set; }

/// <summary>
/// Set to true to automatically loop the sound forever.
/// </summary>
public bool Loop { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/Howler.Blazor/wwwroot/JsInteropHowl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ window.howl = {
src: options.sources,
format: options.formats,
html5: options.html5,
loop: options.loop,

onplay: async function (id) {
let duration = howl.duration(id);
if (duration === Infinity || isNaN(duration)) {
Expand Down

0 comments on commit 3ac027f

Please sign in to comment.