Пример #1
0
        /// <summary>
        /// pathのファイルまたはディレクトリの音声ファイルを読む。
        /// </summary>
        /// <returns>エラーの発生回数。0の時正常終了。</returns>
        public int ReadFileHeader(string path, ReadHeaderMode mode, PlaylistTrackInfo plti)
        {
            int nError = 0;

            if (System.IO.Directory.Exists(path))
            {
                // pathはディレクトリである。直下のファイル一覧を作って足す。再帰的にはたぐらない。
                var files = System.IO.Directory.GetFiles(path);

                if (mSortFolderItem)
                {
                    files = (from s in files orderby s select s).ToArray();
                }

                foreach (var file in files)
                {
                    nError += ReadFileHeader1(file, mode, plti, null);
                }
            }
            else
            {
                // pathはファイル。
                nError += ReadFileHeader1(path, mode, plti, null);
            }
            return(nError);
        }
Пример #2
0
        public PlaylistTrackInfo ConvertToPlaylistTrackInfo()
        {
            PlaylistTrackInfo pti = new PlaylistTrackInfo();

            pti.path      = path;
            pti.title     = title;
            pti.trackId   = trackId;
            pti.startTick = startTick;
            pti.endTick   = endTick;

            pti.indexId            = indexId;
            pti.performer          = performer;
            pti.albumTitle         = albumTitle;
            pti.readSeparatorAfter = readSeparatorAfter;

            return(pti);
        }
Пример #3
0
        public PlaylistTrackInfo ConvertToPlaylistTrackInfo()
        {
            var plti = new PlaylistTrackInfo();

            plti.path      = path;
            plti.title     = string.Empty;
            plti.trackId   = 0;
            plti.startTick = 0;
            plti.endTick   = -1; //< till the last sample

            plti.indexId            = 0;
            plti.performer          = string.Empty;
            plti.albumTitle         = string.Empty;
            plti.readSeparatorAfter = false;

            return(plti);
        }
Пример #4
0
        /// <summary>
        /// pathのファイルまたはディレクトリの音声ファイルを読む。
        /// </summary>
        /// <returns>エラーの発生回数。0の時正常終了。</returns>
        public int ReadFileHeader(string path, ReadHeaderMode mode, PlaylistTrackInfo plti)
        {
            int nError = 0;

            if (System.IO.Directory.Exists(path)) {
                // pathはディレクトリである。直下のファイル一覧を作って足す。再帰的にはたぐらない。
                var files = System.IO.Directory.GetFiles(path);

                if (mSortFolderItem) {
                    files = (from s in files orderby s select s).ToArray();
                }

                foreach (var file in files) {
                    nError += ReadFileHeader1(file, mode, plti, null);
                }
            } else {
                // pathはファイル。
                nError += ReadFileHeader1(path, mode, plti, null);
            }
            return nError;
        }
Пример #5
0
        /// <summary>
        /// N.B. PcmReader.StreamBeginも参照(へぼい)。
        /// MenuItemFileOpen_Clickも参照。
        /// </summary>
        /// <returns>エラーの発生回数を戻す</returns>
        private int ReadFileHeader1(string path, ReadHeaderMode mode,
                                    PlaylistTrackInfo plti, PlaylistItemSave3 plis)
        {
            mPlaylistTrackMeta = plti;
            mPlis = plis;

            int errCount = 0;
            var ext      = System.IO.Path.GetExtension(path).ToUpperInvariant();

            try {
                switch (ext)
                {
                case ".PPWPL":
                    if (mode != ReadHeaderMode.OnlyConcreteFile)
                    {
                        // PPWプレイリストを読み込み
                        errCount += ReadPpwPlaylist(path);
                    }
                    break;

                case ".CUE":
                case ".M3U":
                case ".M3U8":
                    if (mode != ReadHeaderMode.OnlyConcreteFile)
                    {
                        // CUEシートかM3U8再生リストを読み込み。
                        errCount += ReadCueSheet(path);
                    }
                    break;

                case ".FLAC":
                    if (mode != ReadHeaderMode.OnlyMetaFile)
                    {
                        errCount += !ReadFlacFileHeader(path, mode) ? 1 : 0;
                    }
                    break;

                case ".MP3":
                    if (mode != ReadHeaderMode.OnlyMetaFile)
                    {
                        errCount += !ReadMp3FileHeader(path) ? 1 : 0;
                    }
                    break;

                case ".AIF":
                case ".AIFF":
                case ".AIFC":
                case ".AIFFC":
                    if (mode != ReadHeaderMode.OnlyMetaFile)
                    {
                        errCount += !ReadAiffFileHeader(path) ? 1 : 0;
                    }
                    break;

                case ".WAV":
                case ".WAVE":
                    if (mode != ReadHeaderMode.OnlyMetaFile)
                    {
                        errCount += !ReadWavFileHeader(path) ? 1 : 0;
                    }
                    break;

                case ".DSF":
                    if (mode != ReadHeaderMode.OnlyMetaFile)
                    {
                        errCount += !ReadDsfFileHeader(path) ? 1 : 0;
                    }
                    break;

                case ".DFF":
                    if (mode != ReadHeaderMode.OnlyMetaFile)
                    {
                        errCount += !ReadDsdiffFileHeader(path) ? 1 : 0;
                    }
                    break;

                case ".JPG":
                case ".JPEG":
                case ".PNG":
                case ".BMP":
                    // 読まないで無視する。
                    break;

                default:
                    LoadErrorMessageAdd(string.Format(CultureInfo.InvariantCulture, "{0}: {1}{2}",
                                                      Properties.Resources.NotSupportedFileFormat, path, Environment.NewLine));
                    ++errCount;
                    break;
                }
            } catch (IOException ex) {
                HandleFileReadException(path, ex);
                ++errCount;
            } catch (ArgumentException ex) {
                HandleFileReadException(path, ex);
                ++errCount;
            } catch (UnauthorizedAccessException ex) {
                HandleFileReadException(path, ex);
                ++errCount;
            } catch (Exception ex) {
                // 未知のエラー。
                HandleFileReadException(path, ex);
                ++errCount;
            }

            return(errCount);
        }
Пример #6
0
        public PlaylistTrackInfo ConvertToPlaylistTrackInfo()
        {
            var plti = new PlaylistTrackInfo();

            plti.path      = path;
            plti.title     = string.Empty;
            plti.trackId   = 0;
            plti.startTick = 0;
            plti.endTick   = -1; //< till the last sample

            plti.indexId            = 0;
            plti.performer          = string.Empty;
            plti.albumTitle         = string.Empty;
            plti.readSeparatorAfter = false;

            return plti;
        }
Пример #7
0
        /// <summary>
        /// N.B. PcmReader.StreamBeginも参照(へぼい)。
        /// MenuItemFileOpen_Clickも参照。
        /// </summary>
        /// <returns>エラーの発生回数を戻す</returns>
        private int ReadFileHeader1(string path, ReadHeaderMode mode, PlaylistTrackInfo plti, PlaylistItemSave plis)
        {
            mPlaylistTrackMeta = plti;
            mPlis = plis;

            int errCount = 0;
            var ext = System.IO.Path.GetExtension(path).ToUpperInvariant();

            try {
                switch (ext) {
                case ".PPWPL":
                    if (mode != ReadHeaderMode.OnlyConcreteFile) {
                        // PPWプレイリストを読み込み
                        errCount += ReadPpwPlaylist(path);
                    }
                    break;
                case ".CUE":
                case ".M3U":
                case ".M3U8":
                    if (mode != ReadHeaderMode.OnlyConcreteFile) {
                        // CUEシートかM3U8再生リストを読み込み。
                        errCount += ReadCueSheet(path);
                    }
                    break;
                case ".FLAC":
                    if (mode != ReadHeaderMode.OnlyMetaFile) {
                        errCount += !ReadFlacFileHeader(path, mode) ? 1 : 0;
                    }
                    break;
                case ".AIF":
                case ".AIFF":
                case ".AIFC":
                case ".AIFFC":
                    if (mode != ReadHeaderMode.OnlyMetaFile) {
                        errCount += !ReadAiffFileHeader(path) ? 1 : 0;
                    }
                    break;
                case ".WAV":
                case ".WAVE":
                    if (mode != ReadHeaderMode.OnlyMetaFile) {
                        errCount += !ReadWavFileHeader(path) ? 1 : 0;
                    }
                    break;
                case ".DSF":
                    if (mode != ReadHeaderMode.OnlyMetaFile) {
                        errCount += !ReadDsfFileHeader(path) ? 1 : 0;
                    }
                    break;
                case ".DFF":
                    if (mode != ReadHeaderMode.OnlyMetaFile) {
                        errCount += !ReadDsdiffFileHeader(path) ? 1 : 0;
                    }
                    break;
                case ".JPG":
                case ".JPEG":
                case ".PNG":
                case ".BMP":
                    // 読まないで無視する。
                    break;
                default:
                    LoadErrorMessageAdd(string.Format(CultureInfo.InvariantCulture, "{0}: {1}{2}",
                            Properties.Resources.NotSupportedFileFormat, path, Environment.NewLine));
                    ++errCount;
                    break;
                }
            } catch (IOException ex) {
                HandleFileReadException(path, ex);
                ++errCount;
            } catch (ArgumentException ex) {
                HandleFileReadException(path, ex);
                ++errCount;
            } catch (UnauthorizedAccessException ex) {
                HandleFileReadException(path, ex);
                ++errCount;
            } catch (Exception ex) {
                // 未知のエラー。
                HandleFileReadException(path, ex);
                ++errCount;
            }

            return errCount;
        }
Пример #8
0
        public PlaylistTrackInfo ConvertToPlaylistTrackInfo()
        {
            PlaylistTrackInfo pti = new PlaylistTrackInfo();
            pti.path      = path;
            pti.title     = title;
            pti.trackId   = trackId;
            pti.startTick = startTick;
            pti.endTick   = endTick;

            pti.indexId    = indexId;
            pti.performer  = performer;
            pti.albumTitle = albumTitle;
            pti.readSeparatorAfter = readSeparatorAfter;

            return pti;
        }