[longomatch/livecapture2: 13/31] Added timer for live sources
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/livecapture2: 13/31] Added timer for live sources
- Date: Mon, 3 May 2010 22:39:54 +0000 (UTC)
commit a842635fc5e1c63ea81fe5030dbb92b8884c9436
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Mar 31 15:26:35 2010 +0200
Added timer for live sources
CesarPlayer/Capturer/LiveSourceTimer.cs | 87 +++++++++++++++++++++++++++++++
CesarPlayer/Makefile.am | 1 +
2 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/CesarPlayer/Capturer/LiveSourceTimer.cs b/CesarPlayer/Capturer/LiveSourceTimer.cs
new file mode 100644
index 0000000..7a68840
--- /dev/null
+++ b/CesarPlayer/Capturer/LiveSourceTimer.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (C) 2010 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+using System;
+using LongoMatch.Video.Handlers;
+
+
+namespace LongoMatch.Video.Capturer
+{
+
+
+ public class LiveSourceTimer
+ {
+ public event EllpasedTimeHandler EllapsedTime;
+
+ private DateTime lastStart;
+ private TimeSpan ellapsed;
+ private bool playing;
+ private bool started;
+ private uint timerID;
+
+ public LiveSourceTimer()
+ {
+ lastStart = DateTime.Now;
+ ellapsed = new TimeSpan(0,0,0);
+ playing = false;
+ started = false;
+ }
+
+ public int CurrentTime{
+ get{
+ if (!started)
+ return 0;
+ else if (playing)
+ return (int)(ellapsed + (DateTime.Now - lastStart)).TotalMilliseconds;
+ else
+ return (int)ellapsed.TotalMilliseconds;
+ }
+ }
+
+ public void TogglePause(){
+ if (!started)
+ return;
+
+ if (playing){
+ playing = false;
+ ellapsed += DateTime.Now - lastStart;
+ }
+ else{
+ playing = true;
+ lastStart = DateTime.Now;
+ }
+ }
+
+ public void Start(){
+ timerID = GLib.Timeout.Add(100, OnTick);
+ lastStart = DateTime.Now;
+ playing = true;
+ started = true;
+ }
+
+ public void Stop(){
+ GLib.Source.Remove(timerID);
+ }
+
+ protected virtual bool OnTick(){
+ if (EllapsedTime != null)
+ EllapsedTime(CurrentTime);
+ return true;
+ }
+ }
+}
diff --git a/CesarPlayer/Makefile.am b/CesarPlayer/Makefile.am
index a7ffed2..c491121 100644
--- a/CesarPlayer/Makefile.am
+++ b/CesarPlayer/Makefile.am
@@ -82,6 +82,7 @@ FILES = \
Capturer/ErrorHandler.cs \
Capturer/FakeCapturer.cs \
Capturer/ICapturer.cs \
+ Capturer/LiveSourceTimer.cs \
Capturer/ObjectManager.cs \
Editor/ErrorHandler.cs \
Editor/IVideoEditor.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]