Beispiel #1
0
        static BrowseItem fileInfoToBrowseItem(FileInfo fi, bool getMediaDuration, bool setNameToFullPath)
        {
            BrowseItem output = new BrowseItem();

            // Name / path
            if (setNameToFullPath)
            {
                output.Name = fi.FullName;
            }
            else
            {
                output.Name = fi.Name;
            }

            output.Size        = fi.Length;
            output.IsDirectory = false;

            if (getMediaDuration)
            {
                try
                {
                    TimeSpan mDuration = DurationOfMediaFile_OSSpecific(fi.FullName);
                    output.Duration = mDuration.TotalSeconds;
                }
                catch (Exception ex)
                {
                    Functions.WriteLineToLogFileIfAdvanced("Could not get duration of media file: " + fi.FullName + " :");
                    Functions.WriteExceptionToLogFileIfAdvanced(ex);
                }
            }

            return(output);
        }
Beispiel #2
0
        void ConnectCallback(IAsyncResult ar)
        {
            Functions.WriteLineToLogFileIfAdvanced("IRComm: connected to IR Server");

            try
            {
                ClientStateObject obj    = (ClientStateObject)ar.AsyncState;
                TcpClient         client = obj.Client;
                NetworkStream     stream = client.GetStream();

                // Buffer for reading data
                Byte[] bytes      = new Byte[256];
                String strCommand = string.Empty;

                Functions.WriteLineToLogFileIfAdvanced("IRComm: Sending: [" + obj.Command + "]");
                byte[] streamBytes = Encoding.ASCII.GetBytes(obj.Command);
                stream.Write(streamBytes, 0, streamBytes.Length);
                Functions.WriteLineToLogFileIfAdvanced("IRComm: Sent.");

                client.Close();
            }
            catch { }  // ObjectDisposedException if socket is already closed
        }