コード例 #1
0
        public Playlist GetPlaylist(IExtensionToTypeConverter extensionConverter, string file)
        {
            using (ExcelPackage package = new ExcelPackage(new FileInfo(file)))
            {
                List <Clip> clips = new List <Clip>();
                buildPlaylist(extensionConverter, package, clips);
                AddMarks(package, clips);

                return(new Playlist {
                    Clips = clips
                });
            }
        }
コード例 #2
0
        public Playlist GetPlaylist(IExtensionToTypeConverter extensionConverter, string filename)
        {
            try
            {
                string[] filelines = File.ReadAllLines(filename);


                string basePath = filelines[0].Split(',')[0];

                List <Clip> clips = new List <Clip>(filelines.Length - 1);

                for (int i = 1; i < filelines.Length; i++)
                {
                    string[] clipDetails = filelines[i].Split('\t');
                    if (clipDetails[0].StartsWith("#"))
                    {
                        continue;
                    }

                    string   path     = Path.Combine(basePath, clipDetails[0]);
                    ClipType clipType = extensionConverter.GetTypeForExtension(Path.GetExtension(path));
                    clips.Add(new Clip()
                    {
                        FilePath    = path,
                        Type        = File.Exists(path) ? clipType : ClipType.Unknown,
                        DisplayName = clipDetails[1],
                        IsLoop      = bool.Parse(clipDetails[2]),
                        Volume      = double.Parse(clipDetails[3])
                    });
                }

                return(new Playlist()
                {
                    Clips = clips
                });
            }
            catch (Exception e) { return(null); }
        }
コード例 #3
0
        private static void buildPlaylist(IExtensionToTypeConverter extensionConverter, ExcelPackage package, List <Clip> clips)
        {
            string basePath  = package.Workbook.Names["BasePath"].Text;
            var    worksheet = package.Workbook.Worksheets["Playlist"];
            var    table     = worksheet.Tables["Playlist"];

            int tableLeft        = table.Address.Start.Column;
            int displayNameIndex = tableLeft + table.Columns["Clip Display Name"].Position;
            int filePathIndex    = tableLeft + table.Columns["File Path"].Position;
            int loopIndex        = tableLeft + table.Columns["Loop"].Position;
            int volumeIndex      = tableLeft + table.Columns["Volume"].Position;
            int skipIndex        = tableLeft + table.Columns["Skip"].Position;

            // iterate table rows, skipping the header column
            for (int row = table.Address.Start.Row + 1; row <= table.Address.End.Row; row++)
            {
                string displayName = worksheet.Cells[row, displayNameIndex].Text;
                if (string.IsNullOrWhiteSpace(displayName) || worksheet.Cells[row, skipIndex].Text == "Yes")
                {
                    continue;
                }

                string path = worksheet.Cells[row, filePathIndex].Text;
                path = IsFullPath(path) ? path : Path.Combine(basePath, path);
                ClipType clipType = extensionConverter.GetTypeForExtension(Path.GetExtension(path));

                double volume = 0.5;
                double.TryParse(worksheet.Cells[row, volumeIndex].Text, out volume);
                clips.Add(new Clip
                {
                    FilePath    = path,
                    Type        = File.Exists(path) ? clipType : ClipType.Unknown,
                    DisplayName = displayName,
                    IsLoop      = worksheet.Cells[row, loopIndex].Text == "Yes",
                    Volume      = volume
                });
            }
        }
コード例 #4
0
 public Playlist GetPlaylist(IExtensionToTypeConverter extensionConverter, string file)
 {
     return(new Playlist
     {
         Clips = new List <Clip> {
             new Clip {
                 FilePath = @"D:\Video\Liel birthday\Movie5.wmv"
             },
             new Clip {
                 FilePath = @"D:\Video\Liel birthday\Movie14.wmv"
             },
             new Clip {
                 FilePath = @"D:\Video\Liel birthday\Movie12.wmv"
             },
             new Clip {
                 FilePath = @"D:\Video\Liel birthday\Movie7.wmv"
             },
             new Clip {
                 FilePath = @"D:\Video\Liel birthday\Movie2.wmv"
             },
         }
     });
 }