[longomatch] Update media file recursively for playlist elements too



commit bb6b63aef252c276d4e830e45f6c4ea4d1dc2937
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Sep 22 16:45:27 2014 +0200

    Update media file recursively for playlist elements too

 LongoMatch.Core/Store/Project.cs                 |   12 ++++++++++++
 LongoMatch.Core/Store/ProjectDescription.cs      |    4 ++++
 LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs      |   14 +++++++++-----
 LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs |    2 +-
 LongoMatch.Services/Services/ProjectsManager.cs  |    2 +-
 LongoMatch.Services/Services/ToolsManager.cs     |    2 +-
 6 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index 4925fd4..ec173e0 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -174,6 +174,18 @@ namespace LongoMatch.Core.Store
                        Periods.Clear();
                        Timers.Clear();
                }
+               
+               public void UpdateMediaFile (MediaFile file)
+               {
+                       Description.SetMediaFile (file);
+                       foreach (Playlist playlist in Playlists) {
+                               foreach (IPlaylistElement play in playlist.Elements) {
+                                       if (play is PlaylistPlayElement) {
+                                               (play as PlaylistPlayElement).File = file;
+                                       }
+                               }
+                       }
+               }
 
                public void UpdateScore () {
                        Description.LocalGoals = GetScore (Team.LOCAL);
diff --git a/LongoMatch.Core/Store/ProjectDescription.cs b/LongoMatch.Core/Store/ProjectDescription.cs
index 144bbb9..1bea379 100644
--- a/LongoMatch.Core/Store/ProjectDescription.cs
+++ b/LongoMatch.Core/Store/ProjectDescription.cs
@@ -159,5 +159,9 @@ namespace LongoMatch.Core.Store
                        else
                                throw new ArgumentException("object is not a ProjectDescription and cannot be 
compared");
                }
+
+               public void SetMediaFile (MediaFile file) {
+                       File = file;
+               }
        }
 }
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index 64c10ea..fd39e2b 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -289,7 +289,7 @@ namespace LongoMatch.Gui.Panel
                        }
 
                        if (project != null) {
-                               project.Description.File = mediaFile;
+                               project.UpdateMediaFile (mediaFile);
                                return true;
                        }
                        
@@ -312,11 +312,11 @@ namespace LongoMatch.Gui.Panel
                        project.VisitorTeamTemplate = awaytemplate;
                        project.Description = new ProjectDescription ();
                        project.Description.Competition = competitionentry.Text;
-                       project.Description.File = mediaFile;
                        project.Description.MatchDate = datepicker1.Date;
                        project.Description.Season = seasonentry.Text;
                        project.Description.LocalName = project.LocalTeamTemplate.TeamName;
                        project.Description.VisitorName = project.VisitorTeamTemplate.TeamName;
+                       project.UpdateMediaFile (mediaFile);
                        project.UpdateEventTypes ();
                        
                        encSettings = new EncodingSettings ();
@@ -325,9 +325,13 @@ namespace LongoMatch.Gui.Panel
                        encSettings.OutputFile = capturemediafilechooser.File;
                        
                        if (project.Description.File == null) {
-                               project.Description.File = new MediaFile ();
-                               project.Description.File.Fps = (ushort)(Config.FPS_N / Config.FPS_D);
-                               project.Description.File.FilePath = capturemediafilechooser.File;
+                               MediaFile file = new MediaFile ();
+                               file.FilePath = capturemediafilechooser.File;
+                               file.VideoWidth = encSettings.VideoStandard.Width;
+                               file.VideoHeight = encSettings.VideoStandard.Height;
+                               file.Fps = (ushort)(Config.FPS_N / Config.FPS_D);
+                               file.Par = 1;
+                               project.UpdateMediaFile (file);
                        }
                        if (projectType == ProjectType.CaptureProject) {
                                Device device = videoDevices [devicecombobox.Active];
diff --git a/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs 
b/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
index b89ead2..bfa197a 100644
--- a/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
@@ -118,7 +118,7 @@ namespace LongoMatch.Gui.Panel
                void HandleFileChanged (object sender, EventArgs e)
                {
                        if (mediafilechooser.MediaFile != null && loadedProject != null) {
-                               loadedProject.Description.File = mediafilechooser.MediaFile;
+                               loadedProject.UpdateMediaFile (mediafilechooser.MediaFile);
                                fileimage.Pixbuf = loadedProject.Description.File.Preview.Value;
                                medialabel.Markup = loadedProject.Description.File.Description;
                        }
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index e9eecf0..573dfa4 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -143,7 +143,7 @@ namespace LongoMatch.Services
                                RemuxOutputFile (Capturer.CaptureSettings.EncodingSettings);
                        
                                Log.Debug ("Reloading saved file: " + filePath);
-                               project.Description.File = multimediaToolkit.DiscoverFile (filePath);
+                               project.UpdateMediaFile (multimediaToolkit.DiscoverFile (filePath));
                                DB.AddProject (project);
                        } catch (Exception ex) {
                                Log.Exception (ex);
diff --git a/LongoMatch.Services/Services/ToolsManager.cs b/LongoMatch.Services/Services/ToolsManager.cs
index 204e5f1..4d41ef5 100644
--- a/LongoMatch.Services/Services/ToolsManager.cs
+++ b/LongoMatch.Services/Services/ToolsManager.cs
@@ -102,7 +102,7 @@ namespace LongoMatch.Services
                                return;
                        } else {
                                try {
-                                       project.Description.File = multimediaToolkit.DiscoverFile (videofile);
+                                       project.UpdateMediaFile (multimediaToolkit.DiscoverFile (videofile));
                                } catch (Exception ex) {
                                        guiToolkit.ErrorMessage (ex.Message);
                                        return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]