@@ -56,11 +56,24 @@ public PlaylistProcessor(string cplPath) {
5656 Dictionary < string , string > assets = ParseAssetMap ( directory ) ;
5757 Reel reel = new ( ) ;
5858 using XmlReader reader = XmlReader . Create ( cplPath ) ;
59- bool video = true ;
59+ bool video = false ,
60+ audio = false ;
6061 while ( reader . Read ( ) ) {
6162 if ( reader . NodeType != XmlNodeType . Element ) {
62- if ( reader . NodeType == XmlNodeType . EndElement && reader . Name . Equals ( "Reel" ) )
63- Contents . Add ( reel ) ;
63+ if ( reader . NodeType == XmlNodeType . EndElement ) {
64+ switch ( reader . Name ) {
65+ case "Reel" :
66+ Contents . Add ( reel ) ;
67+ break ;
68+ case "MainPicture" :
69+ case "MainStereoscopicPicture" :
70+ video = false ;
71+ break ;
72+ case "MainSound" :
73+ audio = false ;
74+ break ;
75+ }
76+ }
6477 continue ;
6578 } else if ( reader . Name . EndsWith ( "MainStereoscopicPicture" ) ) {
6679 video = true ;
@@ -71,37 +84,40 @@ public PlaylistProcessor(string cplPath) {
7184 case "Id" :
7285 reader . Read ( ) ;
7386 if ( assets . ContainsKey ( reader . Value ) ) {
74- if ( video )
87+ if ( video ) {
7588 reel . videoFile = directory + assets [ reader . Value ] ;
76- else
89+ } else if ( audio ) {
7790 reel . audioFile = directory + assets [ reader . Value ] ;
91+ }
7892 } else { // Try to parse a single reel content with a missing asset map
7993 List < string > bulkAssets = Finder . ForceGetAssets ( directory ) ;
8094 if ( bulkAssets . Count == 2 ) {
8195 long size0 = new FileInfo ( bulkAssets [ 0 ] ) . Length , size1 = new FileInfo ( bulkAssets [ 1 ] ) . Length ;
82- if ( video )
96+ if ( video ) {
8397 reel . videoFile = bulkAssets [ size0 < size1 ? 1 : 0 ] ;
84- else
98+ } else if ( audio ) {
8599 reel . audioFile = bulkAssets [ size1 < size0 ? 1 : 0 ] ;
100+ }
86101 }
87102 }
88103 break ;
89104 case "EntryPoint" :
90105 reader . Read ( ) ;
91- if ( video )
106+ if ( video ) {
92107 reel . videoStartFrame = int . Parse ( reader . Value ) ;
93- else
108+ } else if ( audio ) {
94109 reel . audioStartFrame = int . Parse ( reader . Value ) ;
110+ }
95111 break ;
96112 case "Duration" :
97113 reader . Read ( ) ;
98114 reel . duration = int . Parse ( reader . Value ) ;
99115 break ;
100116 case "FrameRate" :
101117 reader . Read ( ) ;
102- int split = reader . Value . IndexOf ( ' ' ) ;
103118 if ( string . IsNullOrWhiteSpace ( reader . Value ) ) // Handles <FrameRate />
104119 break ;
120+ int split = reader . Value . IndexOf ( ' ' ) ;
105121 reel . framerate = int . Parse ( reader . Value [ ..split ] ) / float . Parse ( reader . Value [ split ..] ) ;
106122 if ( reel . is3D )
107123 reel . framerate *= .5f ;
@@ -113,14 +129,16 @@ public PlaylistProcessor(string cplPath) {
113129 video = true ;
114130 break ;
115131 case "MainSound" :
116- video = false ;
132+ audio = true ;
117133 break ;
118134 case "MainSubtitle" :
119135 case "ns1:AuxData" :
120136 case "axd:AuxData" :
137+ case "axd-cpl:AuxData" :
121138 string name = reader . Name ;
122- while ( reader . Read ( ) &&
123- ( reader . NodeType != XmlNodeType . EndElement || ! reader . Name . Equals ( name ) ) ) ;
139+ while ( reader . Read ( ) && ( reader . NodeType != XmlNodeType . EndElement || ! reader . Name . Equals ( name ) ) ) {
140+ // Skip these blocks, they can't be parsed
141+ }
124142 break ;
125143 case "KeyId" :
126144 reel . needsKey = true ;
0 commit comments