Meadow.Foundation.Audio.Mp3.Yx5300
Yx5300 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Yx5300 mp3Player;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
mp3Player = new Yx5300(Device, Device.PlatformOS.GetSerialPortName("COM4"));
return Task.CompletedTask;
}
public override async Task Run()
{
mp3Player.SetVolume(15);
var status = await mp3Player.GetStatus();
Resolver.Log.Info($"Status: {status}");
var count = await mp3Player.GetNumberOfTracksInFolder(0);
Resolver.Log.Info($"Number of tracks: {count}");
mp3Player.Play();
await Task.Delay(5000); //leave playing for 5 seconds
mp3Player.Next();
await Task.Delay(5000); //leave playing for 5 seconds
}
Sample project(s) available on GitHub
Wiring Example
To wire a Yx5300 to your Meadow board, connect the following:
Yx5300 | Meadow Pin |
---|---|
GND | GND |
VCC | 3.3V |
RX | D01 |
TX | D00 |
Class Yx5300
Represents a Yx5300 serial MP3 player
Assembly: Yx5300.dll
View Source
public class Yx5300 : IDisposable
Implements:
System.IDisposable
Properties
IsDisposed
Is the object disposed
View Source
public bool IsDisposed { get; }
Methods
Reset()
Reset the YX5300 hardware
View Source
public void Reset()
Sleep()
Set the power state to sleep
View Source
public void Sleep()
WakeUp()
Set the power state to normal operations
View Source
public void WakeUp()
SetVolume(byte)
Set volume of YX5300
View Source
public void SetVolume(byte volume)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | volume | byte value from 0-30 |
VolumeUp()
Increase audio volume by 1 (0-30)
View Source
public void VolumeUp()
VolumeDown()
Decrease audio volume by 1 (0-30)
View Source
public void VolumeDown()
GetVolume()
Get audio volume (0-30)
View Source
public Task<byte> GetVolume()
Returns
System.Threading.Tasks.Task<System.Byte>
GetIndexOfCurrentFile()
Get index of currently playing file
View Source
public Task<byte> GetIndexOfCurrentFile()
Returns
System.Threading.Tasks.Task<System.Byte>
GetNumberOfFolders()
Get number of folders
View Source
public Task<byte> GetNumberOfFolders()
Returns
System.Threading.Tasks.Task<System.Byte>
GetNumberOfTracksInFolder(byte)
Get count of mp3 files in folder
View Source
public Task<byte> GetNumberOfTracksInFolder(byte folderIndex)
Returns
System.Threading.Tasks.Task<System.Byte>
Parameters
Type | Name | Description |
---|---|---|
System.Byte | folderIndex | index of folder |
GetStatus()
Get status of YX5300
View Source
public Task<Yx5300.PlayStatus> GetStatus()
Returns
System.Threading.Tasks.Task<Meadow.Foundation.Audio.Mp3.Yx5300.PlayStatus>
: PlayStatus enum### Play()
Play current file
View Source
public void Play()
Play(byte)
Play song at index
View Source
public void Play(byte songIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | songIndex | index of mp3 file in folder |
Next()
Advance to next track
View Source
public void Next()
Previous()
Move back to previous track
View Source
public void Previous()
Pause()
Pause current mp3
View Source
public void Pause()
Stop()
Stop current mp3
View Source
public void Stop()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
public void Dispose()
Dispose(bool)
Dispose of the object
View Source
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Implements
System.IDisposable