using System; namespace AsterNET.FastAGI.Command { /// /// Plays the given file, allowing playback to be interrupted by the given digits, if any.
/// If offset is provided then the audio will seek to sample offset before play starts.
/// Returns 0 if playback completes without a digit being pressed, or the ASCII /// numerical value of the digit if one was pressed, or -1 on error or if the /// channel was disconnected.
/// Remember, the file extension must not be included in the filename. ///
public class StreamFileCommand : AGICommand { #region File /// /// Get/Set the name of the file to stream. /// The name of the file to stream, must not include extension. /// public string File { get { return file; } set { this.file = value; } } #endregion #region EscapeDigits /// /// Get/Set the digits that allow the user to interrupt this command. /// public string EscapeDigits { get { return escapeDigits; } set { this.escapeDigits = value; } } #endregion #region Offset /// /// Get/Set the offset samples to skip before streaming. /// public int Offset { get { return offset; } set { this.offset = value; } } #endregion /// The name of the file to stream. private string file; /// When one of these digits is pressed while streaming the command returns. private string escapeDigits; /// The offset samples to skip before streaming. private int offset; /// Creates a new StreamFileCommand, streaming from the beginning. /// /// /// the name of the file to stream, must not include extension. /// public StreamFileCommand(string file) { this.file = file; this.escapeDigits = null; this.offset = - 1; } /// /// Creates a new StreamFileCommand, streaming from the beginning. /// /// the name of the file to stream, must not include extension. /// contains the digits that allow the user to interrupt this command. public StreamFileCommand(string file, string escapeDigits) { this.file = file; this.escapeDigits = escapeDigits; this.offset = - 1; } /// /// Creates a new StreamFileCommand, streaming from the given offset. /// /// the name of the file to stream, must not include extension. /// contains the digits that allow the user to interrupt this command. /// Maybe null if you don't want the user to interrupt. /// /// the offset samples to skip before streaming. public StreamFileCommand(string file, string escapeDigits, int offset) { this.file = file; this.escapeDigits = escapeDigits; this.offset = offset; } public override string BuildCommand() { return "STREAM FILE " + EscapeAndQuote(file) + " " + EscapeAndQuote(escapeDigits) + (offset < 0?"":" " + offset); } } }