88 lines
No EOL
2.7 KiB
C#
88 lines
No EOL
2.7 KiB
C#
using System;
|
|
using UAF.Remoting;
|
|
using UAF.Remoting.Connections;
|
|
using VegasToTempoBlasterPlugin;
|
|
|
|
namespace DccToolToTempoBlasterPlugin
|
|
{
|
|
public class DccToTempoBlasterPlugin : Plugin
|
|
{
|
|
|
|
public DccToTempoBlasterPlugin()
|
|
: base("TempoBlasterVegasPlugin", new TcpServerConnection("TempoBlasterVegasPlugin"))
|
|
{
|
|
IsPlaying = new RemotePropertyValue<bool>();
|
|
CurrentTime = new RemotePropertyValue<TimeSpan>();
|
|
WavePath = new RemotePropertyValue<string>();
|
|
AudioStartTime = new RemotePropertyValue<TimeSpan>();
|
|
|
|
RegisterHandler("getTrack", blob => this.Send("SetASlaveOfDccTool"));
|
|
RegisterHandler("setBeat", blob => this.CurrentTime.Value = TimeSpan.FromSeconds(blob.ExtractFloat()));
|
|
RegisterHandler("setIsPlaying", blob => this.IsPlaying.Value = blob.ExtractBool());
|
|
RegisterHandler("getWavePath", blob => this.WavePath.Value = blob.ExtractPath());
|
|
Start(new EndPointId("127.0.0.1", 1003));
|
|
}
|
|
|
|
public RemotePropertyValue<TimeSpan> CurrentTime
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public RemotePropertyValue<bool> IsPlaying
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public RemotePropertyValue<string> WavePath
|
|
{
|
|
get; private set;
|
|
}
|
|
|
|
public RemotePropertyValue<TimeSpan> AudioStartTime
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public void UpdatePlayingState(bool isPlaying, TimeSpan currentTime)
|
|
{
|
|
IsPlaying.Value = isPlaying;
|
|
CurrentTime.Value = currentTime;
|
|
|
|
using (IsPlaying.ClearValueChanged())
|
|
using (CurrentTime.ClearValueChanged())
|
|
if (IsPlaying.ValueChanged || CurrentTime.ValueChanged)
|
|
{
|
|
|
|
this.Send("getPlayingState", blob =>
|
|
{
|
|
blob.Push(IsPlaying);
|
|
blob.Push((float)CurrentTime.Value.TotalSeconds);
|
|
blob.Push(0f); // Absolute start beat.
|
|
blob.Push(1f); // Playing state.
|
|
});
|
|
}
|
|
}
|
|
|
|
public void UpdateAudioStartTime(TimeSpan audioStartTime)
|
|
{
|
|
using (AudioStartTime.ClearValueChanged())
|
|
{
|
|
AudioStartTime.Value = audioStartTime;
|
|
if (AudioStartTime.ValueChanged)
|
|
{
|
|
this.Send("AudioStartTime", blob => blob.Push(audioStartTime.TotalMilliseconds));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void AddMarker(TimeSpan markerPosition)
|
|
{
|
|
this.Send("AddMarker", blob => blob.Push(markerPosition.TotalMilliseconds));
|
|
}
|
|
|
|
|
|
}
|
|
} |