Skip to content

Commit

Permalink
add - doc - Added asynchronous play/forget
Browse files Browse the repository at this point in the history
---

To make BassBoom even more suitable for games and other applications,
we've made an asynchronous version of Play-n-Forget functions.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Nov 6, 2024
1 parent 49f65d2 commit 3330c37
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions BassBoom.Basolia/Independent/PlayForget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using BassBoom.Basolia.File;
using BassBoom.Basolia.Playback;
using System.IO;
using System.Threading.Tasks;

namespace BassBoom.Basolia.Independent
{
Expand All @@ -29,7 +30,7 @@ namespace BassBoom.Basolia.Independent
public static class PlayForget
{
/// <summary>
/// Plays the file
/// Plays the file (synchronous)
/// </summary>
/// <param name="path">Path to a music file</param>
/// <param name="settings">Settings of the play/forget technique</param>
Expand All @@ -46,7 +47,15 @@ public static void PlayFile(string path, PlayForgetSettings? settings = null)
}

/// <summary>
/// Plays the stream
/// Plays the file (asynchronous)
/// </summary>
/// <param name="path">Path to a music file</param>
/// <param name="settings">Settings of the play/forget technique</param>
public static async Task PlayFileAsync(string path, PlayForgetSettings? settings = null) =>
await Task.Run(() => PlayFile(path, settings));

/// <summary>
/// Plays the stream (synchronous)
/// </summary>
/// <param name="stream">Stream that contains valid MPEG audio stream</param>
/// <param name="settings">Settings of the play/forget technique</param>
Expand All @@ -62,6 +71,14 @@ public static void PlayStream(Stream stream, PlayForgetSettings? settings = null
PlayAndForget(media, settings);
}

/// <summary>
/// Plays the stream (asynchronous)
/// </summary>
/// <param name="stream">Stream that contains valid MPEG audio stream</param>
/// <param name="settings">Settings of the play/forget technique</param>
public static async Task PlayStreamAsync(Stream stream, PlayForgetSettings? settings = null) =>
await Task.Run(() => PlayStream(stream, settings));

internal static void PlayAndForget(BasoliaMedia media, PlayForgetSettings settings)
{
// Set the volume
Expand Down

0 comments on commit 3330c37

Please sign in to comment.