[longomatch] Fix scenarios without player
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Fix scenarios without player
- Date: Mon, 7 Jul 2014 11:27:58 +0000 (UTC)
commit 1981cb7bbf8a436602d36729ff0868649ef4b9ad
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Jun 10 11:14:32 2014 +0200
Fix scenarios without player
LongoMatch.Services/Services/EventsManager.cs | 16 ++++++++++---
LongoMatch.Services/Services/ProjectsManager.cs | 27 +++++++++++++---------
2 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index 314144a..1578a47 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -100,10 +100,12 @@ namespace LongoMatch.Services
Config.EventsBroker.TagSubcategoriesChangedEvent +=
HandleTagSubcategoriesChangedEvent;
/* Connect player events */
- player.Prev += OnPrev;
- player.SegmentClosedEvent += OnSegmentClosedEvent;
- player.DrawFrame += OnDrawFrame;
- player.PlaybackRateChanged += HandlePlaybackRateChanged;
+ if (player != null) {
+ player.Prev += OnPrev;
+ player.SegmentClosedEvent += OnSegmentClosedEvent;
+ player.DrawFrame += OnDrawFrame;
+ player.PlaybackRateChanged += HandlePlaybackRateChanged;
+ }
}
void HandleTagSubcategoriesChangedEvent (bool tagsubcategories)
@@ -221,6 +223,9 @@ namespace LongoMatch.Services
}
void OnNewTagAtPos (Category category, Time pos) {
+ if (openedProject == null)
+ return;
+
player.CloseSegment();
player.Seek (pos, true);
ProcessNewTag(category,pos);
@@ -228,6 +233,9 @@ namespace LongoMatch.Services
public void OnNewTag(Category category) {
Time pos;
+
+ if (openedProject == null)
+ return;
if(projectType == ProjectType.FakeCaptureProject ||
projectType == ProjectType.CaptureProject ||
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index 837d952..b8ed6a8 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -180,7 +180,18 @@ namespace LongoMatch.Services
Capturer = analysisWindow.Capturer;
OpenedProject = project;
OpenedProjectType = projectType;
-
+
+ if (Player != null) {
+ Player.Tick += Config.EventsBroker.EmitTick;
+ Player.Error += HandleMultimediaError;
+ Player.SegmentClosedEvent += Config.EventsBroker.EmitSegmentClosed;
+ }
+ if (Capturer != null) {
+ Capturer.CaptureFinished += (sender, e) =>
Config.EventsBroker.EmitCloseOpenedProject();
+ if (Capturer != Player)
+ Capturer.Error += HandleMultimediaError;
+ }
+
if(projectType == ProjectType.FileProject) {
// Check if the file associated to the project exists
if(!File.Exists(project.Description.File.FilePath)) {
@@ -199,16 +210,10 @@ namespace LongoMatch.Services
return false;
}
- } else {
- CapturerType type;
- if(projectType == ProjectType.CaptureProject ||
- projectType == ProjectType.URICaptureProject) {
- type = CapturerType.Live;
- } else {
- type = CapturerType.Fake;
- }
+ } else if (projectType == ProjectType.CaptureProject ||
+ projectType == ProjectType.URICaptureProject) {
try {
- Capturer.Run(type, props);
+ Capturer.Run (CapturerType.Live, props);
} catch(Exception ex) {
guiToolkit.ErrorMessage(ex.Message);
CloseOpenedProject (false);
@@ -219,7 +224,7 @@ namespace LongoMatch.Services
EmitProjectChanged();
return true;
}
-
+
/*
public static void ExportToCSV(Project project) {
FileChooserDialog fChooser;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]