mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 17:53:32 +00:00
Added spotify support to Windows Profile
This commit is contained in:
parent
be70786319
commit
1722195529
@ -211,6 +211,10 @@
|
|||||||
<HintPath>..\packages\SharpDX.DXGI.3.0.2\lib\net45\SharpDX.DXGI.dll</HintPath>
|
<HintPath>..\packages\SharpDX.DXGI.3.0.2\lib\net45\SharpDX.DXGI.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="SpotifyAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SpotifyAPI-NET.2.9.0\lib\SpotifyAPI.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
|
|||||||
@ -5,9 +5,11 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
public class WindowsProfileDataModel : IDataModel
|
public class WindowsProfileDataModel : IDataModel
|
||||||
{
|
{
|
||||||
public CpuDataModel Cpu { get; set; }
|
public CpuDataModel Cpu { get; set; }
|
||||||
|
public Spotify Spotify { get; set; }
|
||||||
|
|
||||||
public WindowsProfileDataModel()
|
public WindowsProfileDataModel()
|
||||||
{
|
{
|
||||||
|
Spotify = new Spotify();
|
||||||
Cpu = new CpuDataModel();
|
Cpu = new CpuDataModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,4 +25,15 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
public int Core7Usage { get; set; }
|
public int Core7Usage { get; set; }
|
||||||
public int Core8Usage { get; set; }
|
public int Core8Usage { get; set; }
|
||||||
}
|
}
|
||||||
|
public class Spotify
|
||||||
|
{
|
||||||
|
public string Artist { get; set; }
|
||||||
|
public string SongName { get; set; }
|
||||||
|
public int SongPercentCompleted { get; set; }
|
||||||
|
public int SpotifyVolume { get; set; }
|
||||||
|
public string Album { get; set; }
|
||||||
|
public bool Repeat { get; set; }
|
||||||
|
public bool Shuffle { get; set; }
|
||||||
|
public bool Playing { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -4,6 +4,8 @@ using System.Diagnostics;
|
|||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Models.Profiles;
|
using Artemis.Models.Profiles;
|
||||||
|
using SpotifyAPI.Local;
|
||||||
|
using SpotifyAPI.Local.Models;
|
||||||
|
|
||||||
namespace Artemis.Modules.Effects.WindowsProfile
|
namespace Artemis.Modules.Effects.WindowsProfile
|
||||||
{
|
{
|
||||||
@ -11,12 +13,14 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
{
|
{
|
||||||
private List<PerformanceCounter> _cores;
|
private List<PerformanceCounter> _cores;
|
||||||
private int _cpuFrames;
|
private int _cpuFrames;
|
||||||
|
private readonly SpotifyLocalAPI _spotify;
|
||||||
|
|
||||||
public WindowsProfileModel(MainManager mainManager, WindowsProfileSettings settings)
|
public WindowsProfileModel(MainManager mainManager, WindowsProfileSettings settings)
|
||||||
: base(mainManager, new WindowsProfileDataModel())
|
: base(mainManager, new WindowsProfileDataModel())
|
||||||
{
|
{
|
||||||
Name = "WindowsProfile";
|
Name = "WindowsProfile";
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
|
_spotify = new SpotifyLocalAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WindowsProfileSettings Settings { get; set; }
|
public WindowsProfileSettings Settings { get; set; }
|
||||||
@ -37,15 +41,22 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
coreCount++;
|
coreCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SpotifyLocalAPI.IsSpotifyRunning())
|
||||||
|
{
|
||||||
|
_spotify.Connect();
|
||||||
|
}
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
UpdateCpu();
|
var dataModel = (WindowsProfileDataModel) DataModel;
|
||||||
|
UpdateCpu(dataModel);
|
||||||
|
UpdateSpotify(dataModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateCpu()
|
private void UpdateCpu(WindowsProfileDataModel dataModel)
|
||||||
{
|
{
|
||||||
// CPU is only updated every 15 frames, the performance counter gives 0 if updated too often
|
// CPU is only updated every 15 frames, the performance counter gives 0 if updated too often
|
||||||
_cpuFrames++;
|
_cpuFrames++;
|
||||||
@ -54,8 +65,6 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
|
|
||||||
_cpuFrames = 0;
|
_cpuFrames = 0;
|
||||||
|
|
||||||
var dataModel = (WindowsProfileDataModel)DataModel;
|
|
||||||
|
|
||||||
// Update cores, not ideal but data models don't support lists.
|
// Update cores, not ideal but data models don't support lists.
|
||||||
if (_cores[0] != null)
|
if (_cores[0] != null)
|
||||||
dataModel.Cpu.Core1Usage = (int)_cores[0].NextValue();
|
dataModel.Cpu.Core1Usage = (int)_cores[0].NextValue();
|
||||||
@ -91,5 +100,21 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
}
|
}
|
||||||
return performanceCounters;
|
return performanceCounters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateSpotify(WindowsProfileDataModel dataModel)
|
||||||
|
{
|
||||||
|
StatusResponse status = _spotify.GetStatus();
|
||||||
|
if (status == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dataModel.Spotify.Artist = status.Track.ArtistResource.Name;
|
||||||
|
dataModel.Spotify.SongName = status.Track.TrackResource.Name;
|
||||||
|
dataModel.Spotify.SongPercentCompleted = (int) (status.PlayingPosition/status.Track.Length*100.0);
|
||||||
|
dataModel.Spotify.SpotifyVolume = (int)(status.Volume * 100);
|
||||||
|
dataModel.Spotify.Album = status.Track.AlbumResource.Name;
|
||||||
|
dataModel.Spotify.Repeat = status.Repeat;
|
||||||
|
dataModel.Spotify.Shuffle = status.Shuffle;
|
||||||
|
dataModel.Spotify.Playing = status.Playing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,6 +23,7 @@
|
|||||||
<package id="SharpDX" version="3.0.2" targetFramework="net452" />
|
<package id="SharpDX" version="3.0.2" targetFramework="net452" />
|
||||||
<package id="SharpDX.Direct3D11" version="3.0.2" targetFramework="net452" />
|
<package id="SharpDX.Direct3D11" version="3.0.2" targetFramework="net452" />
|
||||||
<package id="SharpDX.DXGI" version="3.0.2" targetFramework="net452" />
|
<package id="SharpDX.DXGI" version="3.0.2" targetFramework="net452" />
|
||||||
|
<package id="SpotifyAPI-NET" version="2.9.0" targetFramework="net452" />
|
||||||
<package id="System.Linq.Dynamic" version="1.0.6" targetFramework="net452" />
|
<package id="System.Linq.Dynamic" version="1.0.6" targetFramework="net452" />
|
||||||
<package id="VirtualInput" version="1.0.1" targetFramework="net452" />
|
<package id="VirtualInput" version="1.0.1" targetFramework="net452" />
|
||||||
<package id="WpfExceptionViewer" version="1.0.0.0" targetFramework="net452" />
|
<package id="WpfExceptionViewer" version="1.0.0.0" targetFramework="net452" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user