mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-01-14 22:18:43 +00:00
Add workflow to upload to nuget.org on release + add some examples to README
This commit is contained in:
parent
c0d2ac48f6
commit
588bc92c00
5
.github/workflows/build-and-test.yml
vendored
5
.github/workflows/build-and-test.yml
vendored
@ -10,8 +10,7 @@ jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: windows-latest # For a list of available runner types, refer to
|
||||
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
|
||||
runs-on: windows-latest
|
||||
|
||||
env:
|
||||
Solution_Name: MpcNET
|
||||
@ -40,7 +39,7 @@ jobs:
|
||||
dotnet nuget add source --username Difegue --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Difegue/index.json"
|
||||
dotnet build $env:Solution_Name --configuration $env:Configuration
|
||||
dotnet pack --configuration $env:Configuration -o ./
|
||||
dotnet nuget push *.nupkg --api-key ${{ secrets.PRIVATE_TOKEN }} --source "github"
|
||||
dotnet nuget push *.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github"
|
||||
|
||||
# Execute all unit tests in the solution
|
||||
- name: Execute unit tests
|
||||
|
39
.github/workflows/release.yml
vendored
Normal file
39
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: New Version Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
env:
|
||||
Solution_Name: MpcNET
|
||||
Configuration: Release
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
|
||||
- name: Setup MSBuild.exe
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
# Restore the application
|
||||
- name: Restore the application
|
||||
working-directory: ./Sources
|
||||
run: |
|
||||
msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
|
||||
|
||||
# Build package and upload to github packages
|
||||
- name: Build package
|
||||
working-directory: ./Sources
|
||||
run: |
|
||||
dotnet build $env:Solution_Name --configuration $env:Configuration
|
||||
dotnet pack --configuration $env:Configuration -o ./
|
||||
dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_API }} --source "nuget.org"
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,3 +34,4 @@ Sources/.DS_Store
|
||||
Sources/Stylophone.iOS/bin
|
||||
Sources/Stylophone.iOS/obj
|
||||
.DS_Store
|
||||
/Sources/MpcNET.1.0.0.nupkg
|
||||
|
76
README.md
76
README.md
@ -13,7 +13,7 @@ var mpdEndpoint = new IPEndPoint(IPAddress.Loopback, 6600);
|
||||
````
|
||||
Then create a Client and Connect to MPD.
|
||||
````C#
|
||||
var client = new Mpc(mpdEndpoint);
|
||||
var client = new MpcConnection(mpdEndpoint);
|
||||
var connected = await client.ConnectAsync();
|
||||
````
|
||||
The `ConnectAsync()` method is returning a bool to indicate if the connection was successfully. However, this can be queried directly on the Client also:
|
||||
@ -28,6 +28,78 @@ To disconnect the Client use the follow method:
|
||||
````C#
|
||||
await client.DisconnectAsync();
|
||||
````
|
||||
or just dispose the client:
|
||||
````C#
|
||||
client.Dispose();
|
||||
````
|
||||
### Send Command
|
||||
|
||||
## API Content
|
||||
````C#
|
||||
using (var client = new MpcConnection(mpdEndpoint)) {
|
||||
await client.ConnectAsync();
|
||||
|
||||
// Look in /Commands to see everything that implements IMpcCommand
|
||||
var request = await client.SendAsync(new IMpcCommand<List<string>>(parameters));
|
||||
|
||||
if (!request.IsResponseValid) {
|
||||
var mpdError = request.Response?.Result?.MpdError;
|
||||
if (mpdError != null && mpdError != "")
|
||||
Console.WriteLine($"Error: {mpdError}");
|
||||
else
|
||||
Console.WriteLine($"Invalid server response: {response}.");
|
||||
|
||||
} else {
|
||||
List<string> response = request.Response.Content;
|
||||
// do stuff
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
### Command Lists
|
||||
|
||||
````C#
|
||||
var commandList = new CommandList();
|
||||
|
||||
commandList.Add(new IMpcCommand<?>(firstCommandArgument);
|
||||
commandList.Add(new IMpcCommand<?>(secondCommandArgument);
|
||||
commandList.Add(new IMpcCommand<?>(thirdCommandArgument);
|
||||
|
||||
using (var client = new MpcConnection(mpdEndpoint)) {
|
||||
await client.ConnectAsync();
|
||||
var request = await client.SendAsync(commandList);
|
||||
|
||||
// Response string contains responses of all the commands, split by commas
|
||||
string response = request.Response?.Content;
|
||||
}
|
||||
|
||||
````
|
||||
|
||||
### Binary Responses
|
||||
|
||||
````C#
|
||||
// Get albumart from MPD
|
||||
List<byte> data = new List<byte>();
|
||||
|
||||
using (var client = new MpcConnection(mpdEndpoint))
|
||||
{
|
||||
long totalBinarySize = 9999;
|
||||
long currentSize = 0;
|
||||
|
||||
do
|
||||
{
|
||||
var albumReq = await client.SendAsync(new AlbumArtCommand(f.Path, currentSize));
|
||||
if (!albumReq.IsResponseValid) break;
|
||||
|
||||
var response = albumReq.Response.Content;
|
||||
if (response.Binary == 0) break; // MPD isn't giving us any more data, let's roll with what we have.
|
||||
|
||||
totalBinarySize = response.Size;
|
||||
currentSize += response.Binary;
|
||||
data.AddRange(response.Data);
|
||||
|
||||
Debug.WriteLine($"Downloading albumart: {currentSize}/{totalBinarySize}");
|
||||
} while (currentSize < totalBinarySize);
|
||||
}
|
||||
|
||||
````
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user