[longomatch] Remove Tick event from the IPlayer API
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Remove Tick event from the IPlayer API
- Date: Mon, 28 Jul 2014 13:38:09 +0000 (UTC)
commit f88f1a30746babbfcf45b5bc8ec98db71fc027e5
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Jul 14 18:07:34 2014 +0200
Remove Tick event from the IPlayer API
LongoMatch.Core/Common/EventsBroker.cs | 4 +-
LongoMatch.Core/Handlers/Multimedia.cs | 2 +-
LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs | 1 -
LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs | 37 ++++++++++++++--------
LongoMatch.GUI/Gui/Component/CodingWidget.cs | 2 +-
LongoMatch.GUI/Gui/Component/ProjectPeriods.cs | 2 +-
LongoMatch.Multimedia/Player/GstPlayer.cs | 5 ---
7 files changed, 29 insertions(+), 24 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsBroker.cs b/LongoMatch.Core/Common/EventsBroker.cs
index ed48c8f..d78e337 100644
--- a/LongoMatch.Core/Common/EventsBroker.cs
+++ b/LongoMatch.Core/Common/EventsBroker.cs
@@ -306,10 +306,10 @@ namespace LongoMatch.Common
}
}
- public void EmitTick (Time currentTime, Time streamLength, double currentPosition)
+ public void EmitTick (Time currentTime)
{
if (Tick != null) {
- Tick (currentTime, streamLength, currentPosition);
+ Tick (currentTime);
}
}
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 06732b5..d4bfac1 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -41,7 +41,7 @@ namespace LongoMatch.Handlers
public delegate void ErrorHandler(string message);
public delegate void PercentCompletedHandler(float percent);
public delegate void StateChangeHandler(bool playing);
- public delegate void TickHandler(Time currentTime, Time streamLength, double currentPosition);
+ public delegate void TickHandler(Time currentTime);
public delegate void EosHandler();
public delegate void ReadyToSeekHandler();
}
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
b/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
index 2f6b58e..53af50f 100644
--- a/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
+++ b/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
@@ -32,7 +32,6 @@ namespace LongoMatch.Interfaces.Multimedia
event ErrorHandler Error;
event System.EventHandler Eos;
event StateChangeHandler StateChange;
- event TickHandler Tick;
event ReadyToSeekHandler ReadyToSeek;
Time StreamLength {get;}
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index ec084f6..8459421 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -69,6 +69,8 @@ namespace LongoMatch.Gui
Seeker seeker;
Segment segment;
Blackboard blackboard;
+ uint timeout;
+ bool ignoreTick;
#region Constructors
@@ -93,6 +95,7 @@ namespace LongoMatch.Gui
segment.Start = new Time(-1);
segment.Stop = new Time(int.MaxValue);
lastTime = new Time (0);
+ length = new Time (0);
CreatePlayer ();
}
@@ -100,7 +103,8 @@ namespace LongoMatch.Gui
#endregion
protected override void OnDestroyed ()
{
- player.Dispose();
+ player.Dispose ();
+ blackboard.Dispose ();
base.OnDestroyed ();
}
@@ -168,6 +172,7 @@ namespace LongoMatch.Gui
#region Public methods
public void Open (string filename) {
+ timeout = GLib.Timeout.Add (20, OnTick);
Open (filename, true);
}
@@ -217,7 +222,10 @@ namespace LongoMatch.Gui
}
public void Close() {
- player.Tick -= OnTick;
+ if (timeout != 0) {
+ GLib.Source.Remove (timeout);
+ timeout = 0;
+ }
player.Close();
filename = null;
timescale.Value = 0;
@@ -370,9 +378,9 @@ namespace LongoMatch.Gui
void LoadDrawing (FrameDrawing drawing) {
Pause ();
- player.Tick -= OnTick;
+ ignoreTick = true;
player.Seek (drawing.Render, true);
- player.Tick += OnTick;
+ ignoreTick = false;
blackboard.Background = player.GetCurrentFrame () ;
blackboard.Drawing = drawing;
DrawingsVisible = true;
@@ -427,7 +435,6 @@ namespace LongoMatch.Gui
videodrawingarea.DoubleBuffered = false;
player = Config.MultimediaToolkit.GetPlayer ();
- player.Tick += OnTick;
player.Error += Config.EventsBroker.EmitMultimediaError;
player.StateChange += OnStateChanged;
player.Eos += OnEndOfStream;
@@ -463,6 +470,7 @@ namespace LongoMatch.Gui
void OnReadyToSeek() {
readyToSeek = true;
+ length = player.StreamLength;
if(pendingSeek != null) {
player.Rate = (float) pendingSeek [1];
player.Seek ((Time)pendingSeek[0], true);
@@ -473,13 +481,15 @@ namespace LongoMatch.Gui
}
}
- void OnTick (Time currentTime, Time streamLength, double currentPosition) {
+ bool OnTick () {
string slength;
+ Time currentTime;
- if (length != streamLength) {
- length = streamLength;
+ if (ignoreTick) {
+ return true;
}
+ currentTime = CurrentTime;
if (SegmentLoaded) {
Time dur, ct;
double cp;
@@ -503,16 +513,17 @@ namespace LongoMatch.Gui
slength = length.ToMSecondsString ();
timelabel.Text = currentTime.ToMSecondsString() + "/" + slength;
if (timescale.Visible) {
- timescale.Value = currentPosition;
+ timescale.Value = (double) currentTime.MSeconds / length.MSeconds;
}
}
lastTime = currentTime;
if (Tick != null) {
- Tick (currentTime, streamLength, currentPosition);
+ Tick (currentTime);
}
- Config.EventsBroker.EmitTick (currentTime, streamLength, currentPosition);
+ Config.EventsBroker.EmitTick (currentTime);
+ return true;
}
void OnTimescaleAdjustBounds(object o, Gtk.AdjustBoundsArgs args)
@@ -522,7 +533,7 @@ namespace LongoMatch.Gui
if(!seeking) {
seeking = true;
IsPlayingPrevState = player.Playing;
- player.Tick -= OnTick;
+ ignoreTick = true;
Pause ();
seeksQueue [0] = -1;
seeksQueue [1] = -1;
@@ -542,7 +553,7 @@ namespace LongoMatch.Gui
* We need to cache previous position and seek again to the this position */
SeekFromTimescale(seeksQueue[0] != -1 ? seeksQueue[0] : seeksQueue[1]);
seeking=false;
- player.Tick += OnTick;
+ ignoreTick = false;
if(IsPlayingPrevState)
Play ();
}
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index 1ad6a67..8214c46 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -129,7 +129,7 @@ namespace LongoMatch.Gui.Component
}
}
- void HandleTick (Time currentTime, Time streamLength, double currentPosition)
+ void HandleTick (Time currentTime)
{
timeline.CurrentTime = currentTime;
}
diff --git a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
index bde4890..4907878 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
@@ -95,7 +95,7 @@ namespace LongoMatch.Gui.Component
}
}
- void HandleTick (Time currentTime, Time streamLength, double currentPosition)
+ void HandleTick (Time currentTime)
{
timerule.CurrentTime = currentTime;
timersTimenline.CurrentTime = currentTime;
diff --git a/LongoMatch.Multimedia/Player/GstPlayer.cs b/LongoMatch.Multimedia/Player/GstPlayer.cs
index dd2217f..6c3531d 100644
--- a/LongoMatch.Multimedia/Player/GstPlayer.cs
+++ b/LongoMatch.Multimedia/Player/GstPlayer.cs
@@ -105,11 +105,6 @@ namespace LongoMatch.Video.Player {
StateChange (args.Playing);
};
- this.GlibTick += (o, args) => {
- if (Tick != null)
- Tick (args.CurrentTime, args.StreamLength, args.CurrentPosition);
- };
-
this.GlibReadyToSeek += (sender, e) => {
if (ReadyToSeek != null)
ReadyToSeek ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]