client/src/Iri.Modernisation.Data/Ldt/Readers.cs
changeset 35 43bb1b8ed555
parent 34 4d9ebc6fbbe8
child 38 bd33267300aa
equal deleted inserted replaced
34:4d9ebc6fbbe8 35:43bb1b8ed555
    16     {
    16     {
    17         public static VideoBook ConvertToVideoBook(XDocument Path)
    17         public static VideoBook ConvertToVideoBook(XDocument Path)
    18         {
    18         {
    19             LDTFile _ldtFile = new LDTFile();
    19             LDTFile _ldtFile = new LDTFile();
    20             _ldtFile.Load(Path);
    20             _ldtFile.Load(Path);
       
    21            
    21             VideoBook _videoBook = new VideoBook();
    22             VideoBook _videoBook = new VideoBook();
       
    23             
    22             if (_ldtFile != null)
    24             if (_ldtFile != null)
    23             {
    25             {
    24                 // Initialisation du VideoBook
    26                 // Initialisation du VideoBook
    25                 _videoBook = new VideoBook()
    27                 _videoBook = new VideoBook()
    26                 {
    28                 {
    30                         UserName = _ldtFile.Project.User,
    32                         UserName = _ldtFile.Project.User,
    31                         
    33                         
    32                     },
    34                     },
    33                     Duration = new TimeSpan(),
    35                     Duration = new TimeSpan(),
    34                     IriPath = _ldtFile.Medias[0].Src,
    36                     IriPath = _ldtFile.Medias[0].Src,
    35                     LdtPath = Path.BaseUri,
    37                     LdtPath = _ldtFile.Path,
    36 
    38 
    37                 };
    39                 };
    38 
    40 
    39                 // Initialisation des index
    41                 // Initialisation des index
    40                 foreach (LDTAnnotationsContent LDTAC in _ldtFile.Annotations)
    42                 foreach (LDTAnnotationsContent LDTAC in _ldtFile.Annotations)
   105             {
   107             {
   106                 throw new Exception("Fichier LDT Null");
   108                 throw new Exception("Fichier LDT Null");
   107             }
   109             }
   108 
   110 
   109         }
   111         }
       
   112         public static VideoBook ConvertToVideoBook(LDTFile ldt, IRIFile iri)
       
   113         {
       
   114             VideoBook _videoBook = new VideoBook();
       
   115             // Initialisation du VideoBook
       
   116             _videoBook = new VideoBook()
       
   117             {
       
   118                 Title = ldt.Project.Title,
       
   119                 Author = new User()
       
   120                 {
       
   121                     UserName = ldt.Project.User,
       
   122 
       
   123                 },
       
   124                 Duration = new TimeSpan(),
       
   125                 IriPath = ldt.Medias[0].Src,
       
   126                 LdtPath = ldt.Path,
       
   127 
       
   128             };
       
   129 
       
   130             // Initialisation des index
       
   131             
       
   132             foreach (LDTAnnotationsContent LDTAC in ldt.Annotations)
       
   133             {
       
   134                 //int count = 0;
       
   135                 int decoupage = LDTAC.Content[2].Elements.Count / 4;
       
   136                 //int selectedChapter = 0;
       
   137 
       
   138                 for (int eloop = 0; eloop < iri.Body.Ensembles.Count; eloop++)
       
   139                 {
       
   140                     if (iri.Body.Ensembles[eloop].Id == "VideoBookIndex")
       
   141                     {
       
   142                         for (int dloop = 0; dloop < iri.Body.Ensembles[eloop].Decoupages.Count; dloop++)
       
   143                         {
       
   144                             if(iri.Body.Ensembles[eloop].Decoupages[dloop].Id=="Index")
       
   145                             {
       
   146                                 foreach (IRIElement elem in iri.Body.Ensembles[eloop].Decoupages[dloop].Elements)
       
   147                                 {
       
   148                                     _videoBook.Chapters[elem.Chapter].Index.Add(new SegmentIndex(_videoBook.Chapters[elem.Chapter])
       
   149                                     {
       
   150                                         Id = elem.Id,
       
   151                                         Title = elem.Title,
       
   152                                         Description = elem.Abstract,
       
   153                                         Tags = elem.Tags,
       
   154                                         TimerIn = elem.Begin,
       
   155                                         Duration = elem.Dur
       
   156 
       
   157                                     });
       
   158                                 }
       
   159                             }
       
   160                         }
       
   161                         break;
       
   162                         
       
   163                     }
       
   164                 }
       
   165                 /*
       
   166                 foreach (LDTElement LDTE in LDTAC.Content[2].Elements)
       
   167                 {
       
   168                     _videoBook.Chapters[selectedChapter].Index.Add(new SegmentIndex(_videoBook.Chapters[selectedChapter])
       
   169                     {
       
   170                         Id = LDTE.Id,
       
   171                         Title = LDTE.Title,
       
   172                         Description = LDTE.Abstract,
       
   173                         Tags = LDTE.Tags,
       
   174                         TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin),
       
   175                         Duration = new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur),
       
   176 
       
   177                     });
       
   178                     count++;
       
   179                     if (count % decoupage == 0)
       
   180                     {
       
   181                         selectedChapter++;
       
   182                         if (selectedChapter >= 4)
       
   183                         {
       
   184                             selectedChapter = 3;
       
   185                         }
       
   186                     }
       
   187 
       
   188                     _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur));
       
   189                 }*/
       
   190                 foreach (LDTElement LDTE in LDTAC.Content[3].Elements)
       
   191                 {
       
   192                     _videoBook.Chapters[0].Annotations.Add(new Annotation(_videoBook.Chapters[0])
       
   193                     {
       
   194                         Id = LDTE.Id,
       
   195                         Title = LDTE.Title,
       
   196                         Description = LDTE.Abstract,
       
   197                         Tags = LDTE.Tags,
       
   198                         TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin),
       
   199                         Duration = new TimeSpan(0, 0, 0, 0, (int)(LDTE.Dur + 5000)),
       
   200                         Type = FactoryVideoLivre.AnnotationDescriptions[0]
       
   201                     });
       
   202                     // _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)(LDTE.Dur)));
       
   203                 }
       
   204                 foreach (LDTElement LDTE in LDTAC.Content[1].Elements)
       
   205                 {
       
   206                     _videoBook.Chapters[0].Annotations.Add(new Annotation(_videoBook.Chapters[0])
       
   207                     {
       
   208                         Title = LDTE.Title,
       
   209                         Description = LDTE.Abstract,
       
   210                         Tags = LDTE.Tags,
       
   211                         TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin),
       
   212                         Duration = new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur),
       
   213                         Type = FactoryVideoLivre.AnnotationDescriptions[1]
       
   214                     });
       
   215                     // _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur));
       
   216                 }
       
   217 
       
   218             }
       
   219             return _videoBook;
       
   220         }
   110     }
   221     }
   111 }
   222 }