private static MCIResult ProcessMCIRequest(MCIRequest request, IntPtr hwndHandle = new IntPtr()) { var mciResult = new MCIResult(); StringBuilder ret = null; if (request.retLen > 0) { ret = new StringBuilder(request.retLen); } // send the command string to the MCI mciResult.ReturnValue = mciSendString(request.MCICommand, ret, request.retLen, hwndHandle); // if an error was returned, raise the event, and throw exception if appropriate if (mciResult.IsError()) { var buffer = new StringBuilder(128); mciGetErrorString(mciResult.ReturnValue, buffer, 128); ret = buffer; } if (ret != null) { mciResult.ReturnMessage = ret.ToString(); } else { mciResult.ReturnMessage = string.Empty; } if (mciResult.IsError()) { if (Error != null) { Error(new MCIErrorEventArgs(request.MCICommand, mciResult.ReturnValue, mciResult.ReturnMessage)); } if (MCIErrorsThrowExceptions) { throw new MediaPlayerException(request.MCICommand, mciResult.ReturnValue, mciResult.ReturnMessage); } } #if DEBUG Console.WriteLine(string.Format("Sent at: {4} Tick Count: {0} Command: {1} Result: {2} '{3}'", Environment.TickCount, request.MCICommand, mciResult.ReturnValue.ToString(), mciResult.ReturnMessage, request.Tick)); #endif return(mciResult); }
private MCIResult SendMCICommand(string mciCommand, int retLen) { var mciResult = new MCIResult(); StringBuilder ret = null; if (retLen > 0) { ret = new StringBuilder(retLen); } // send the command string to the MCI mciResult.ReturnValue = mciSendString(mciCommand, ret, retLen, IntPtr.Zero); // if an error was returned, raise the event, and throw exception if appropriate if (mciResult.IsError()) { var buffer = new StringBuilder(128); mciGetErrorString(mciResult.ReturnValue, buffer, 128); ret = buffer; } if (ret != null) { mciResult.ReturnMessage = ret.ToString(); } else { mciResult.ReturnMessage = string.Empty; } return(mciResult); }
private MCIResult SendMCICommand(string mciCommand, int retLen) { var mciResult = new MCIResult(); StringBuilder ret = null; if (retLen > 0) ret = new StringBuilder(retLen); // send the command string to the MCI mciResult.ReturnValue = mciSendString(mciCommand, ret, retLen, IntPtr.Zero); // if an error was returned, raise the event, and throw exception if appropriate if (mciResult.IsError()) { var buffer = new StringBuilder(128); mciGetErrorString(mciResult.ReturnValue, buffer, 128); ret = buffer; } if (ret != null) mciResult.ReturnMessage = ret.ToString(); else mciResult.ReturnMessage = string.Empty; return mciResult; }
private static MCIResult ProcessMCIRequest(MCIRequest request, IntPtr hwndHandle = new IntPtr()) { var mciResult = new MCIResult(); StringBuilder ret = null; if (request.retLen > 0) ret = new StringBuilder(request.retLen); // send the command string to the MCI mciResult.ReturnValue = mciSendString(request.MCICommand, ret, request.retLen, hwndHandle); // if an error was returned, raise the event, and throw exception if appropriate if (mciResult.IsError()) { var buffer = new StringBuilder(128); mciGetErrorString(mciResult.ReturnValue, buffer, 128); ret = buffer; } if (ret != null) mciResult.ReturnMessage = ret.ToString(); else mciResult.ReturnMessage = string.Empty; if (mciResult.IsError()) { if (Error != null) Error(new MCIErrorEventArgs(request.MCICommand, mciResult.ReturnValue, mciResult.ReturnMessage)); if (MCIErrorsThrowExceptions) throw new MediaPlayerException(request.MCICommand, mciResult.ReturnValue, mciResult.ReturnMessage); } #if DEBUG Console.WriteLine(string.Format("Sent at: {4} Tick Count: {0} Command: {1} Result: {2} '{3}'", Environment.TickCount, request.MCICommand, mciResult.ReturnValue.ToString(), mciResult.ReturnMessage, request.Tick)); #endif return mciResult; }