client/src/Iri.Modernisation.Data/Ldt/Readers.cs
changeset 38 bd33267300aa
parent 35 43bb1b8ed555
child 39 0f2bde8fdfeb
--- a/client/src/Iri.Modernisation.Data/Ldt/Readers.cs	Wed Jan 27 10:55:59 2010 +0100
+++ b/client/src/Iri.Modernisation.Data/Ldt/Readers.cs	Thu Feb 04 16:38:04 2010 +0100
@@ -111,9 +111,10 @@
         }
         public static VideoBook ConvertToVideoBook(LDTFile ldt, IRIFile iri)
         {
-            VideoBook _videoBook = new VideoBook();
+           
+          
             // Initialisation du VideoBook
-            _videoBook = new VideoBook()
+           VideoBook _videoBook = new VideoBook()
             {
                 Title = ldt.Project.Title,
                 Author = new User()
@@ -124,98 +125,60 @@
                 Duration = new TimeSpan(),
                 IriPath = ldt.Medias[0].Src,
                 LdtPath = ldt.Path,
+                MediaPath = iri.Body.Medias[0].Videos[0].Src
 
             };
 
             // Initialisation des index
-            
+              TimeSpan totalDur = TimeSpan.Zero;
+            foreach(IRIEnsemble Iens in iri.Body.Ensembles)
+            {
+                int chapter = 0;
+              
+                foreach (IRIElement elem in Iens.Decoupages[0].Elements)
+                {
+                    _videoBook.Chapters[chapter].Index.Add(new SegmentIndex(_videoBook.Chapters[chapter])
+                    {
+                        Id = elem.Id,
+                        Title = elem.Title,
+                        Description = elem.Abstract,
+                        Tags = elem.Tags,
+                        TimerIn = elem.Begin,
+                        Duration = elem.Dur
+
+                    });
+                    totalDur += elem.Dur;
+                }
+                chapter++;
+            }
+           
             foreach (LDTAnnotationsContent LDTAC in ldt.Annotations)
             {
-                //int count = 0;
-                int decoupage = LDTAC.Content[2].Elements.Count / 4;
-                //int selectedChapter = 0;
-
-                for (int eloop = 0; eloop < iri.Body.Ensembles.Count; eloop++)
-                {
-                    if (iri.Body.Ensembles[eloop].Id == "VideoBookIndex")
-                    {
-                        for (int dloop = 0; dloop < iri.Body.Ensembles[eloop].Decoupages.Count; dloop++)
-                        {
-                            if(iri.Body.Ensembles[eloop].Decoupages[dloop].Id=="Index")
-                            {
-                                foreach (IRIElement elem in iri.Body.Ensembles[eloop].Decoupages[dloop].Elements)
-                                {
-                                    _videoBook.Chapters[elem.Chapter].Index.Add(new SegmentIndex(_videoBook.Chapters[elem.Chapter])
-                                    {
-                                        Id = elem.Id,
-                                        Title = elem.Title,
-                                        Description = elem.Abstract,
-                                        Tags = elem.Tags,
-                                        TimerIn = elem.Begin,
-                                        Duration = elem.Dur
-
-                                    });
-                                }
-                            }
-                        }
-                        break;
-                        
-                    }
-                }
-                /*
-                foreach (LDTElement LDTE in LDTAC.Content[2].Elements)
-                {
-                    _videoBook.Chapters[selectedChapter].Index.Add(new SegmentIndex(_videoBook.Chapters[selectedChapter])
-                    {
-                        Id = LDTE.Id,
-                        Title = LDTE.Title,
-                        Description = LDTE.Abstract,
-                        Tags = LDTE.Tags,
-                        TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin),
-                        Duration = new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur),
+               int chapterIndex = 0;
+               foreach(LDTAnnotationsDecoupage LDTAD  in LDTAC.Content)
+               {
+                   User author = new User() {UserName = LDTAD.Author };
+                   foreach(LDTElement elem in LDTAD.Elements)
+                   {
+                       _videoBook.Chapters[chapterIndex].Annotations.Add(
+                           new Annotation(_videoBook.Chapters[chapterIndex])
+                           {
+                               Title = elem.Title,
+                               Description = elem.Abstract,
+                               Tags = elem.Tags,
+                               TimerIn = new TimeSpan(0, 0, 0, 0, (int)elem.Begin),
+                               Duration = new TimeSpan(0, 0, 0, 0, (int)elem.Dur),
+                               Type = FactoryVideoLivre.AnnotationDescriptions[elem.Type],
+                               Contributer = author
 
-                    });
-                    count++;
-                    if (count % decoupage == 0)
-                    {
-                        selectedChapter++;
-                        if (selectedChapter >= 4)
-                        {
-                            selectedChapter = 3;
-                        }
-                    }
-
-                    _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur));
-                }*/
-                foreach (LDTElement LDTE in LDTAC.Content[3].Elements)
-                {
-                    _videoBook.Chapters[0].Annotations.Add(new Annotation(_videoBook.Chapters[0])
-                    {
-                        Id = LDTE.Id,
-                        Title = LDTE.Title,
-                        Description = LDTE.Abstract,
-                        Tags = LDTE.Tags,
-                        TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin),
-                        Duration = new TimeSpan(0, 0, 0, 0, (int)(LDTE.Dur + 5000)),
-                        Type = FactoryVideoLivre.AnnotationDescriptions[0]
-                    });
-                    // _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)(LDTE.Dur)));
-                }
-                foreach (LDTElement LDTE in LDTAC.Content[1].Elements)
-                {
-                    _videoBook.Chapters[0].Annotations.Add(new Annotation(_videoBook.Chapters[0])
-                    {
-                        Title = LDTE.Title,
-                        Description = LDTE.Abstract,
-                        Tags = LDTE.Tags,
-                        TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin),
-                        Duration = new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur),
-                        Type = FactoryVideoLivre.AnnotationDescriptions[1]
-                    });
-                    // _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur));
-                }
-
+                           });
+                   }
+                 
+               }
+               chapterIndex++;
             }
+            _videoBook.Duration = iri.Body.Medias[0].Videos[0].Dur;
+            _videoBook.LdtPath = ldt.Path;
             return _videoBook;
         }
     }