Compare commits
No commits in common. "vlc" and "master" have entirely different histories.
2 changed files with 76 additions and 66 deletions
|
|
@ -50,9 +50,6 @@
|
||||||
<Package>gtk-sharp-2.0</Package>
|
<Package>gtk-sharp-2.0</Package>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Net" />
|
|
||||||
<Reference Include="System.Web.Http" />
|
|
||||||
<Reference Include="Mono.Http" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="gtk-gui\gui.stetic">
|
<EmbeddedResource Include="gtk-gui\gui.stetic">
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ using System.Threading;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +33,7 @@ namespace DMX2
|
||||||
|
|
||||||
SeqSonUI ui=null;
|
SeqSonUI ui=null;
|
||||||
|
|
||||||
//Process mplayerProcess = null;
|
Process mplayerProcess = null;
|
||||||
|
|
||||||
List<string> files = new List<string>();
|
List<string> files = new List<string>();
|
||||||
|
|
||||||
|
|
@ -43,10 +41,7 @@ namespace DMX2
|
||||||
|
|
||||||
uint volume=100;
|
uint volume=100;
|
||||||
|
|
||||||
System.Net.WebClient wc =new System.Net.WebClient();
|
|
||||||
String vlcPassword = "loupiottes";
|
|
||||||
string credentials;
|
|
||||||
string vlcUrl = "http://127.0.0.1:8080/requests/status.json";
|
|
||||||
|
|
||||||
TimeSpan fading=TimeSpan.Zero;
|
TimeSpan fading=TimeSpan.Zero;
|
||||||
TimeSpan fadeLen;
|
TimeSpan fadeLen;
|
||||||
|
|
@ -85,33 +80,43 @@ namespace DMX2
|
||||||
|
|
||||||
bool Paused{ get; set;}
|
bool Paused{ get; set;}
|
||||||
|
|
||||||
bool CheckVLC(){
|
bool CheckMplayer(){
|
||||||
|
if (mplayerProcess == null || mplayerProcess.HasExited) {
|
||||||
|
if (mplayerProcess != null)
|
||||||
|
mplayerProcess.Dispose ();
|
||||||
|
ProcessStartInfo startinfo = new ProcessStartInfo ();
|
||||||
|
startinfo.FileName = "mplayer";
|
||||||
|
startinfo.Arguments = "-quiet -idle -slave";
|
||||||
|
startinfo.RedirectStandardInput = true;
|
||||||
|
startinfo.RedirectStandardOutput = true;
|
||||||
|
startinfo.UseShellExecute = false;
|
||||||
|
|
||||||
|
mplayerProcess = Process.Start (startinfo);
|
||||||
|
mplayerProcess.OutputDataReceived += ProcessMplayerOut;
|
||||||
|
mplayerProcess.BeginOutputReadLine ();
|
||||||
|
return !mplayerProcess.HasExited;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendCommand(string command, string input)
|
void ProcessMplayerOut (object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
string url;
|
string data = e.Data;
|
||||||
if (input != null)
|
if (data == null)
|
||||||
{
|
|
||||||
string encodedInput = Uri.EscapeDataString(input);
|
|
||||||
url = $"{vlcUrl}?command={command}&input={encodedInput}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
url = $"{vlcUrl}?command={command}";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string response = wc.DownloadString(url);
|
|
||||||
Console.WriteLine("Réponse VLC : " + response);
|
|
||||||
return;
|
return;
|
||||||
|
if (data.StartsWith ("ANS_LENGTH")) {
|
||||||
|
string d = data.Substring (11);
|
||||||
|
double dData;
|
||||||
|
if(double.TryParse(d,NumberStyles.Number,CultureInfo.InvariantCulture,out dData))
|
||||||
|
duration = TimeSpan.FromSeconds( dData );
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
if (data.StartsWith ("ANS_TIME_POSITION")) {
|
||||||
{
|
string d = data.Substring (18);
|
||||||
Console.WriteLine("Erreur lors de l'ajout du fichier : " + e.Message);
|
double dData;
|
||||||
return;
|
if(double.TryParse(d,NumberStyles.Number,CultureInfo.InvariantCulture,out dData))
|
||||||
|
position = TimeSpan.FromSeconds( dData );
|
||||||
}
|
}
|
||||||
|
Console.WriteLine ("data => {0}", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AddFile (int pos, string file)
|
public int AddFile (int pos, string file)
|
||||||
|
|
@ -128,24 +133,28 @@ namespace DMX2
|
||||||
get{ return volume;}
|
get{ return volume;}
|
||||||
set {
|
set {
|
||||||
volume=value;
|
volume=value;
|
||||||
uint val = volume * 255 / 100;
|
if (mplayerProcess != null && !mplayerProcess.HasExited)
|
||||||
//if (mplayerProcess != null && !mplayerProcess.HasExited)
|
{
|
||||||
//{
|
if (!Paused)
|
||||||
// if (!Paused)
|
mplayerProcess.StandardInput.WriteLine("volume {0} 1", volume);
|
||||||
// mplayerProcess.StandardInput.WriteLine("volume {0} 1", volume);
|
}
|
||||||
//}
|
|
||||||
SendCommand($"volume&val={val}",null);
|
|
||||||
volumeEventTarget.FeedBack ();
|
volumeEventTarget.FeedBack ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan PlayTime {
|
public TimeSpan PlayTime {
|
||||||
get{
|
get{
|
||||||
|
if (mplayerProcess != null && !mplayerProcess.HasExited)
|
||||||
|
{
|
||||||
|
if (!Paused)
|
||||||
|
mplayerProcess.StandardInput.WriteLine("get_time_pos");
|
||||||
|
|
||||||
|
}
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
set{
|
set{
|
||||||
if (CheckVLC ()) {
|
if (CheckMplayer ()) {
|
||||||
|
mplayerProcess.StandardInput.WriteLine ("seek {0} 2", value.TotalMilliseconds / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -170,11 +179,16 @@ namespace DMX2
|
||||||
|
|
||||||
curfile = files[pos];
|
curfile = files[pos];
|
||||||
Stop();
|
Stop();
|
||||||
|
//mplayerProcess.StandardInput.WriteLine ("volume 0 1"); // old
|
||||||
SendCommand("pl_empty", curfile);
|
mplayerProcess.StandardInput.WriteLine ("volume {0} 1", volume);
|
||||||
|
mplayerProcess.StandardInput.WriteLine ("pausing loadfile \"{0}\"", curfile);
|
||||||
SendCommand("in_play", curfile);
|
mplayerProcess.StandardInput.WriteLine ("pausing get_time_length");
|
||||||
|
//mplayerProcess.StandardInput.WriteLine("loadfile \"{0}\"", curfile); //old
|
||||||
|
//mplayerProcess.StandardInput.WriteLine("get_time_length"); //old
|
||||||
|
////mplayerProcess.StandardInput.WriteLine ("pausing seek 0 2"); //old
|
||||||
|
//mplayerProcess.StandardInput.WriteLine ("pause"); //old
|
||||||
|
//mplayerProcess.StandardInput.WriteLine ("seek 0 2"); //old
|
||||||
|
//mplayerProcess.StandardInput.WriteLine ("volume {0} 1", volume); //old
|
||||||
Paused = true;
|
Paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,9 +196,10 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
if (curfile==null || !Paused)
|
if (curfile==null || !Paused)
|
||||||
return;
|
return;
|
||||||
if (!CheckVLC ())
|
if (!CheckMplayer ())
|
||||||
return;
|
return;
|
||||||
SendCommand("pl_play", null);
|
mplayerProcess.StandardInput.WriteLine ("pause");
|
||||||
|
mplayerProcess.StandardInput.WriteLine ("volume {0} 1", volume);
|
||||||
Paused = false;
|
Paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,26 +207,20 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
if (curfile==null || Paused)
|
if (curfile==null || Paused)
|
||||||
return;
|
return;
|
||||||
if (!CheckVLC ())
|
if (!CheckMplayer ())
|
||||||
return;
|
return;
|
||||||
SendCommand("pl_pause", null);
|
mplayerProcess.StandardInput.WriteLine ("pause");
|
||||||
|
|
||||||
Paused = true;
|
Paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop ()
|
public void Stop ()
|
||||||
{
|
{
|
||||||
CheckVLC ();
|
CheckMplayer ();
|
||||||
SendCommand("pl_stop", null);
|
mplayerProcess.StandardInput.WriteLine ("stop");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SequenceurSon ()
|
public SequenceurSon ()
|
||||||
{
|
{
|
||||||
credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(":" + vlcPassword));
|
|
||||||
wc.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
|
|
||||||
|
|
||||||
|
|
||||||
volumeEventTarget = new actionEventTargetEx (
|
volumeEventTarget = new actionEventTargetEx (
|
||||||
delegate(EventData data) {
|
delegate(EventData data) {
|
||||||
Volume = (uint)(100 * data.value / 255);
|
Volume = (uint)(100 * data.value / 255);
|
||||||
|
|
@ -455,7 +464,11 @@ namespace DMX2
|
||||||
#region IDisposable implementation
|
#region IDisposable implementation
|
||||||
void IDisposable.Dispose ()
|
void IDisposable.Dispose ()
|
||||||
{
|
{
|
||||||
|
if (mplayerProcess != null && !mplayerProcess.HasExited) {
|
||||||
|
mplayerProcess.StandardInput.WriteLine ("quit");
|
||||||
|
if (!mplayerProcess.WaitForExit (1000))
|
||||||
|
mplayerProcess.Kill ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue