private void HandleMediaPlayerOutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
if (e.Data != null)
{
string line = e.Data.ToString();
if (line.StartsWith("EOF code:", StringComparison.Ordinal))
{
this._finalfilecode = line.Substring("EOF code:".Length);
if (this._finalfilecode != null)
{
this.Finalfile?.Invoke(this, new MplayerEvent(this._finalfilecode));
}
}
else if (line.Contains("Scanning file") || line.Contains("get_path"))
{
this._scanning = line;
if (this._scanning != null)
{
this.Scanfonts?.Invoke(this, new MplayerEvent(this._scanning));
}
}
else if (line.StartsWith("ID_FILE_SUB_FILENAME=", StringComparison.Ordinal))
{
this._filesub = line.Substring("ID_FILE_SUB_FILENAME=".Length);
if (this._filesub != null)
{
this.Filesub?.Invoke(this, new MplayerEvent(this._filesub));
}
}
else if (line.StartsWith("ID_AID_", StringComparison.Ordinal))
{
this._audiochannel = line.Substring("ID_AID_".Length);
if (this._audiochannel != null)
{
this.Audiochannel?.Invoke(this, new MplayerEvent(this._audiochannel));
}
}
else if (line.StartsWith("ID_SID_", StringComparison.Ordinal))
{
this._setaudiolang = line.Substring("ID_SID_".Length);
if (this._setaudiolang != null)
{
this.Setaudiolang?.Invoke(this, new MplayerEvent(this._setaudiolang));
}
}
else if (line.StartsWith("ANS_PERCENT_POSITION=", StringComparison.Ordinal))
{
this._percentpos = line.Substring("ANS_PERCENT_POSITION=".Length);
}
else if (line.StartsWith("Cache fill:", StringComparison.Ordinal))
{
this._cache = line.Substring("Cache fill:".Length);
if (this._cache != null)
{
this.Cache?.Invoke(this, new MplayerEvent(this._cache));
}
}
else if (line.StartsWith("ANS_AUDIO_BITRATE=", StringComparison.Ordinal)) //audio bitrate
{
this._getfileinfofilename = line.Substring("ANS_AUDIO_BITRATE=".Length);
}
else if (line.StartsWith("ANS_AUDIO_CODEC=", StringComparison.Ordinal)) //audio codec
{
this._getfileinfofilename = line.Substring("ANS_AUDIO_CODEC=".Length);
}
else if (line.StartsWith("ANS_AUDIO_SAMPLES=", StringComparison.Ordinal)) //audio sample
{
this._getfileinfofilename = line.Substring("ANS_AUDIO_SAMPLES=".Length);
}
else if (line.StartsWith("ANS_FILENAME=")) //audio filename
{
this._getfileinfofilename = line.Substring("ANS_FILENAME=".Length);
}
else if (line.StartsWith("ANS_META_ALBUM=")) //album
{
this._getfileinfofilename = line.Substring("ANS_META_ALBUM=".Length);
}
else if (line.StartsWith("ANS_META_ARTIST=", StringComparison.Ordinal)) //artista
{
this._getfileinfofilename = line.Substring("ANS_META_ARTIST=".Length);
}
else if (line.StartsWith("ANS_META_COMMENT=", StringComparison.Ordinal)) //comentarios
{
this._getfileinfofilename = line.Substring("ANS_META_COMMENT=".Length);
}
else if (line.StartsWith("ANS_META_GENRE=", StringComparison.Ordinal)) //genero
{
this._getfileinfofilename = line.Substring("ANS_META_GENRE=".Length);
}
else if (line.StartsWith("ANS_META_TITLE=", StringComparison.Ordinal)) //titulo
{
this._getinfotitle = line.Substring("ANS_META_TITLE=".Length);
}
else if (line.StartsWith("ANS_META_TRACK=", StringComparison.Ordinal)) //track
{
this._getfileinfofilename = line.Substring("ANS_META_TRACK=".Length);
}
else if (line.StartsWith("ANS_META_YEAR=", StringComparison.Ordinal)) //ano
{
this._getfileinfofilename = line.Substring("ANS_META_YEAR=".Length);
}
else if (line.StartsWith("ANS_VIDEO_BITRATE=", StringComparison.Ordinal)) //video bitrate
{
this._getfileinfofilename = line.Substring("ANS_VIDEO_BITRATE=".Length);
}
else if (line.StartsWith("ANS_VIDEO_RESOLUTION=", StringComparison.Ordinal)) //video resoluçao
{
this._getfileinfofilename = line.Substring("ANS_VIDEO_RESOLUTION=".Length);
}
else if (line.StartsWith("ANS_TIME_POSITION=", StringComparison.Ordinal))
{
this._currentPosition = (int)Globals.FloatParse(line.Substring("ANS_TIME_POSITION=".Length));
this.CurrentPosition?.Invoke(this, new MplayerEvent(this._currentPosition));
}
else if (line.StartsWith("ANS_length=", StringComparison.Ordinal))
{
this._totalTime = (int)Globals.FloatParse(line.Substring("ANS_length=".Length));
}
else if (line.StartsWith("Exiting", StringComparison.Ordinal) || line.ToLower().StartsWith("eof code", StringComparison.Ordinal))
{
this.VideoExited?.Invoke(this, new MplayerEvent("Exiting File"));
}
//System.Console.WriteLine(line);
}
}