Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig → src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,36 @@ dotnet_diagnostic.CA1308.severity = none
dotnet_diagnostic.CA1716.severity = none
dotnet_diagnostic.CA1720.severity = none
dotnet_diagnostic.CA2101.severity = none
dotnet_diagnostic.CA2234.severity = none
dotnet_diagnostic.CA5350.severity = none
dotnet_diagnostic.CA9998.severity = none

dotnet_diagnostic.CS1591.severity = none

dotnet_diagnostic.IDE0002.severity = none
dotnet_diagnostic.IDE0021.severity = warning
dotnet_diagnostic.IDE0022.severity = warning
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0059.severity = none

dotnet_diagnostic.SA1108.severity = none
dotnet_diagnostic.SA1117.severity = none
dotnet_diagnostic.SA1121.severity = none
dotnet_diagnostic.SA1122.severity = none
dotnet_diagnostic.SA1131.severity = none
dotnet_diagnostic.SA1201.severity = none
dotnet_diagnostic.SA1202.severity = none
dotnet_diagnostic.SA1203.severity = none
dotnet_diagnostic.SA1204.severity = none
dotnet_diagnostic.SA1214.severity = none
dotnet_diagnostic.SA1309.severity = none
dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1513.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1601.severity = none
dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1629.severity = none
dotnet_diagnostic.SA1633.severity = none

dotnet_diagnostic.SX1309.severity = warning
dotnet_diagnostic.SX1309S.severity = warning
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30128.74
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyPremiumPlugin", "win\SpotifyPremiumPlugin.csproj", "{D7B32254-4248-4A43-B127-706810EFCAFA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyPlugin", "SpotifyPremiumPlugin\SpotifyPlugin.csproj", "{D7B32254-4248-4A43-B127-706810EFCAFA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Loupedeck.SpotifyPremiumPlugin
{
using System;
using SpotifyAPI.Web.Models;

internal class PlayAndNavigateAdjustment : PluginDynamicAdjustment
{
Expand All @@ -24,11 +23,11 @@ protected override void ApplyAdjustment(String actionParameter, Int32 ticks)
{
if (ticks > 0)
{
this.SpotifyPremiumPlugin.CheckSpotifyResponse(this.SkipPlaybackToNext);
this.SpotifyPremiumPlugin.Wrapper.SkipPlaybackToNext();
}
else
{
this.SpotifyPremiumPlugin.CheckSpotifyResponse(this.SkipPlaybackToPrevious);
this.SpotifyPremiumPlugin.Wrapper.SkipPlaybackToPrevious();
}
}
catch (Exception e)
Expand All @@ -42,7 +41,7 @@ protected override void RunCommand(String actionParameter)
{
try
{
this.SpotifyPremiumPlugin.CheckSpotifyResponse(this.TogglePlayback);
this.SpotifyPremiumPlugin.Wrapper.TogglePlayback();
}
catch (Exception e)
{
Expand All @@ -56,17 +55,5 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma
var bitmapImage = EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width50.PlayAndNavigateTracks.png");
return bitmapImage;
}

public ErrorResponse SkipPlaybackToNext() => this.SpotifyPremiumPlugin.Api.SkipPlaybackToNext(this.SpotifyPremiumPlugin.CurrentDeviceId);

public ErrorResponse SkipPlaybackToPrevious() => this.SpotifyPremiumPlugin.Api.SkipPlaybackToPrevious(this.SpotifyPremiumPlugin.CurrentDeviceId);

public ErrorResponse TogglePlayback()
{
var playback = this.SpotifyPremiumPlugin.Api.GetPlayback();
return playback.IsPlaying
? this.SpotifyPremiumPlugin.Api.PausePlayback(this.SpotifyPremiumPlugin.CurrentDeviceId)
: this.SpotifyPremiumPlugin.Api.ResumePlayback(this.SpotifyPremiumPlugin.CurrentDeviceId, String.Empty, null, String.Empty, 0);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright(c) Loupedeck.All rights reserved.

namespace Loupedeck.SpotifyPremiumPlugin
{
using System;

internal class SpotifyVolumeAdjustment : PluginDynamicAdjustment
{
private SpotifyPremiumPlugin SpotifyPremiumPlugin => this.Plugin as SpotifyPremiumPlugin;

public SpotifyVolumeAdjustment()
: base("Spotify Volume", "Spotify Volume description", "Spotify Volume", true)
{
}

protected override void ApplyAdjustment(String actionParameter, Int32 ticks) => this.SpotifyPremiumPlugin.Wrapper.SetVolume(ticks);

// Overwrite the RunCommand method that is called every time the user presses the encoder to which this command is assigned
protected override void RunCommand(String actionParameter) => this.SpotifyPremiumPlugin.Wrapper.TogglePlayback();

protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
// Dial strip 50px
var bitmapImage = EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width50.Volume.png");
return bitmapImage;
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Loupedeck.SpotifyPremiumPlugin.CommandFolders
using System.Collections.Generic;
using System.Linq;

using SpotifyAPI.Web.Models;
using SpotifyAPI.Web;

/// <summary>
/// Dynamic folder (control center) for Spotify devices. https://developer.loupedeck.com/docs/Actions-taxonomy
Expand All @@ -32,10 +32,9 @@ public override BitmapImage GetButtonImage(PluginImageSize imageSize)

public override IEnumerable<String> GetButtonPressActionNames()
{
this._devices = this.SpotifyPremiumPlugin?.Api?.GetDevices()?.Devices;
this._devices = this.SpotifyPremiumPlugin.Wrapper.GetDevices();
if (this._devices != null && this._devices.Any())
{
this._devices.Add(new Device { Id = "activedevice", Name = "Active Device" });
return this._devices.Select(x => this.CreateCommandName(x.Id));
}

Expand All @@ -54,29 +53,6 @@ public override String GetCommandDisplayName(String commandParameter, PluginImag
return deviceDisplayName;
}

public override void RunCommand(String commandParameter)
{
try
{
this.SpotifyPremiumPlugin.CheckSpotifyResponse(this.TransferPlayback, commandParameter);
}
catch (Exception e)
{
Tracer.Trace($"Spotify DeviceSelectorCommandFolder action obtain an error: ", e);
}
}

public ErrorResponse TransferPlayback(String commandParameter)
{
if (commandParameter == "activedevice")
{
commandParameter = String.Empty;
}

this.SpotifyPremiumPlugin.CurrentDeviceId = commandParameter;
this.SpotifyPremiumPlugin.SaveDeviceToCache(commandParameter);

return this.SpotifyPremiumPlugin.Api.TransferPlayback(this.SpotifyPremiumPlugin.CurrentDeviceId, true);
}
public override void RunCommand(String commandParameter) => this.SpotifyPremiumPlugin.Wrapper.TransferPlayback(commandParameter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright(c) Loupedeck.All rights reserved.

namespace Loupedeck.SpotifyPremiumPlugin
{
using System;

using SpotifyAPI.Web;

internal class ChangeRepeatStateCommand : PluginDynamicCommand
{
private SpotifyPremiumPlugin SpotifyPremiumPlugin => this.Plugin as SpotifyPremiumPlugin;

public ChangeRepeatStateCommand()
: base("Change Repeat State", "Change Repeat State description", "Playback")
{
}

protected override void RunCommand(String actionParameter) => this.SpotifyPremiumPlugin.Wrapper.ChangeRepeatState();

protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
String icon;
switch (this.SpotifyPremiumPlugin.Wrapper.CachedRepeatState)
{
case PlayerSetRepeatRequest.State.Off:
icon = "Loupedeck.SpotifyPremiumPlugin.Icons.Width80.RepeatOff.png";
break;

case PlayerSetRepeatRequest.State.Context:
icon = "Loupedeck.SpotifyPremiumPlugin.Icons.Width80.RepeatList.png";
break;

case PlayerSetRepeatRequest.State.Track:
icon = "Loupedeck.SpotifyPremiumPlugin.Icons.Width80.Repeat.png";
break;

default:
// Set plugin status and message
icon = "Loupedeck.SpotifyPremiumPlugin.Icons.Width80.RepeatOff.png";
break;
}

var bitmapImage = EmbeddedResources.ReadImage(icon);
return bitmapImage;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,22 @@
namespace Loupedeck.SpotifyPremiumPlugin
{
using System;
using SpotifyAPI.Web.Models;

internal class NextTrackCommand : PluginDynamicCommand
{
private SpotifyPremiumPlugin SpotifyPremiumPlugin => this.Plugin as SpotifyPremiumPlugin;

public NextTrackCommand()
: base(
"Next Track",
"Next Track description",
"Playback")
: base("Next Track", "Next Track description", "Playback")
{
}

protected override void RunCommand(String actionParameter)
{
try
{
this.SpotifyPremiumPlugin.CheckSpotifyResponse(this.SkipPlaybackToNext);
}
catch (Exception e)
{
Tracer.Trace($"Spotify NextTrackCommand action obtain an error: ", e);
}
}
protected override void RunCommand(String actionParameter) => this.SpotifyPremiumPlugin.Wrapper.SkipPlaybackToNext();

protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
var bitmapImage = EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.NextTrack.png");
return bitmapImage;
}

public ErrorResponse SkipPlaybackToNext() => this.SpotifyPremiumPlugin.Api.SkipPlaybackToNext(this.SpotifyPremiumPlugin.CurrentDeviceId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,22 @@
namespace Loupedeck.SpotifyPremiumPlugin
{
using System;
using SpotifyAPI.Web.Models;

internal class PreviousTrackCommand : PluginDynamicCommand
{
private SpotifyPremiumPlugin SpotifyPremiumPlugin => this.Plugin as SpotifyPremiumPlugin;

public PreviousTrackCommand()
: base(
"Previous Track",
"Previous Track description",
"Playback")
: base("Previous Track", "Previous Track description", "Playback")
{
}

protected override void RunCommand(String actionParameter)
{
try
{
this.SpotifyPremiumPlugin.CheckSpotifyResponse(this.SkipPlaybackToPrevious);
}
catch (Exception e)
{
Tracer.Trace($"Spotify PreviousTrackCommand action obtain an error: ", e);
}
}
protected override void RunCommand(String actionParameter) => this.SpotifyPremiumPlugin.Wrapper.SkipPlaybackToPrevious();

protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
var bitmapImage = EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.PreviousTrack.png");
return bitmapImage;
}

public ErrorResponse SkipPlaybackToPrevious() => this.SpotifyPremiumPlugin.Api.SkipPlaybackToPrevious(this.SpotifyPremiumPlugin.CurrentDeviceId);
}
}
25 changes: 25 additions & 0 deletions src/SpotifyPremiumPlugin/Commands/Playback/ShufflePlayCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright(c) Loupedeck.All rights reserved.

namespace Loupedeck.SpotifyPremiumPlugin
{
using System;

internal class ShufflePlayCommand : PluginDynamicCommand
{
private SpotifyPremiumPlugin SpotifyPremiumPlugin => this.Plugin as SpotifyPremiumPlugin;

public ShufflePlayCommand()
: base("Shuffle Play", "Shuffle Play description", "Playback")
{
}

protected override void RunCommand(String actionParameter) => this.SpotifyPremiumPlugin.Wrapper.ShufflePlay();

protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
return this.SpotifyPremiumPlugin.Wrapper.CachedShuffleState ?
EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.Shuffle.png") :
EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.ShuffleOff.png");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright(c) Loupedeck.All rights reserved.

namespace Loupedeck.SpotifyPremiumPlugin
{
using System;

internal class TogglePlaybackCommand : PluginDynamicCommand
{
private SpotifyPremiumPlugin SpotifyPremiumPlugin => this.Plugin as SpotifyPremiumPlugin;

public TogglePlaybackCommand()
: base("Toggle Playback", "Toggles audio playback", "Playback")
{
}

protected override void RunCommand(String actionParameter) => this.SpotifyPremiumPlugin.Wrapper.TogglePlayback();

protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
return this.SpotifyPremiumPlugin.Wrapper.CachedPlayingState ?
EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.Play.png") :
EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.Pause.png");
}
}
}
25 changes: 25 additions & 0 deletions src/SpotifyPremiumPlugin/Commands/ToggleLikeCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright(c) Loupedeck.All rights reserved.

namespace Loupedeck.SpotifyPremiumPlugin
{
using System;

internal class ToggleLikeCommand : PluginDynamicCommand
{
private SpotifyPremiumPlugin SpotifyPremiumPlugin => this.Plugin as SpotifyPremiumPlugin;

public ToggleLikeCommand()
: base("Toggle Like", "Toggle Like", "Others")
{
}

protected override void RunCommand(String actionParameter) => this.SpotifyPremiumPlugin.Wrapper.ToggleLike();

protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
return this.SpotifyPremiumPlugin.Wrapper.CachedLikeState ?
EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.SongLike.png") :
EmbeddedResources.ReadImage("Loupedeck.SpotifyPremiumPlugin.Icons.Width80.SongDislike.png");
}
}
}
Loading