Beispiel #1
0
        public bool ReadFromFile(TagData.PictureStreamHandlerDelegate pictureStreamHandler, bool readAllMetaFrames = false)
        {
            bool result = false;

            LogDelegator.GetLocateDelegate()(fileName);

            resetData();

            try
            {
                // Open file, read first block of data and search for a frame
                using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, fileOptions))
                    using (BinaryReader source = new BinaryReader(fs))
                    {
                        result = read(source, pictureStreamHandler, readAllMetaFrames);
                    }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.WriteLine(e.StackTrace);
                LogDelegator.GetLogDelegate()(Log.LV_ERROR, e.Message);
                result = false;
            }

            return(result);
        }
Beispiel #2
0
        private bool read(BinaryReader source, TagData.PictureStreamHandlerDelegate pictureStreamHandler = null, bool readAllMetaFrames = false, bool prepareForWriting = false)
        {
            sizeInfo.ResetData();

            sizeInfo.FileSize = source.BaseStream.Length;
            MetaDataIO.ReadTagParams readTagParams = new MetaDataIO.ReadTagParams(pictureStreamHandler, readAllMetaFrames);
            readTagParams.PrepareForWriting = prepareForWriting;

            return(read(source, readTagParams));
        }
Beispiel #3
0
        public Boolean ReadFromFile(TagData.PictureStreamHandlerDelegate pictureStreamHandler,
                                    Boolean readAllMetaFrames = false)
        {
            var result = false;

            LogDelegator.GetLocateDelegate()(fileName);

            resetData();

            try
            {
                // Open file, read first block of data and search for a frame
                var s = (null == stream)
                    ? new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, fileOptions)
                    : stream;
                var source = new BinaryReader(s);
                try
                {
                    result = read(source, pictureStreamHandler, readAllMetaFrames);
                }
                finally
                {
                    if (null == stream)
                    {
                        source.Close();
                    }
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                throw new AudioDataCorruptionException(
                          "Possible audio data corruption, check Inner Exception for details", e);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.WriteLine(e.StackTrace);
                LogDelegator.GetLogDelegate()(Log.LV_ERROR, e.Message);
                result = false;
            }

            return(result);
        }
Beispiel #4
0
 public ReadTagParams(TagData.PictureStreamHandlerDelegate pictureStreamHandler, bool readAllMetaFrames)
 {
     PictureStreamHandler = pictureStreamHandler; ReadAllMetaFrames = readAllMetaFrames;
 }