[longomatch] Simplify PlayerCapturerBin
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Simplify PlayerCapturerBin
- Date: Tue, 31 Mar 2015 17:29:52 +0000 (UTC)
commit 70514a15d08a7c76591846ef7f693e2be86bb01c
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Mar 20 18:27:41 2015 +0100
Simplify PlayerCapturerBin
LongoMatch.Core/Handlers/Multimedia.cs | 10 +
LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs | 1 +
LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs | 4 +
LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs | 273 +++-----------------
LongoMatch.GUI/Gui/Component/AnalysisComponent.cs | 14 +-
5 files changed, 64 insertions(+), 238 deletions(-)
---
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 1711500..fc31a4d 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -36,6 +36,7 @@ namespace LongoMatch.Core.Handlers
public delegate void DrawFrameHandler (TimelineEvent play,int drawingIndex,int cameraIndex,bool
current);
public delegate void EllpasedTimeHandler (Time ellapsedTime);
public delegate void PlaybackRateChangedHandler (float rate);
+ public delegate void PrepareLoadEventHandler (MediaFileSet fileset);
public delegate void DeviceChangeHandler (int deviceID);
public delegate void CaptureFinishedHandler (bool close);
@@ -43,7 +44,16 @@ namespace LongoMatch.Core.Handlers
public delegate void PercentCompletedHandler (float percent);
public delegate void StateChangeHandler (bool playing);
public delegate void TickHandler (Time currentTime);
+ public delegate void TimeChangedHandler (Time currentTime,Time duration,bool seekable);
public delegate void MediaInfoHandler (int width,int height,int parN,int parD);
public delegate void EosHandler ();
public delegate void ReadyToSeekHandler ();
+
+ public delegate void LoadImageHander (Image image,FrameDrawing frameDrawing);
+
+ public delegate void ElementLoadedHandler (bool hasNext);
+
+ public delegate void ElementUnloadedHandler ();
+
+ public delegate void PARChangedHandler (float par);
}
diff --git a/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs b/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
index 1eb8c32..7cff6b6 100644
--- a/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
@@ -28,6 +28,7 @@ namespace LongoMatch.Core.Interfaces.GUI
public interface IPlayerBin
{
event StateChangeHandler PlayStateChanged;
+ event PrepareLoadEventHandler PrepareLoadEvent;
Time CurrentTime { get; }
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index d449d62..e34a66d 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -55,6 +55,7 @@ namespace LongoMatch.Gui
public event TickHandler Tick;
public event StateChangeHandler PlayStateChanged;
public event EventHandler CloseEvent;
+ public event PrepareLoadEventHandler PrepareLoadEvent;
const int THUMBNAIL_MAX_WIDTH = 100;
const int SCALE_FPS = 25;
@@ -331,6 +332,9 @@ namespace LongoMatch.Gui
public void LoadPlay (MediaFileSet fileSet, TimelineEvent evt, Time seekTime, bool playing)
{
+ if (PrepareLoadEvent != null) {
+ PrepareLoadEvent (fileSet);
+ }
loadedPlaylist = null;
loadedPlaylistElement = null;
loadedPlay = evt;
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
index 05404cc..562e97c 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
@@ -21,35 +21,32 @@ using LongoMatch.Core.Handlers;
using LongoMatch.Core.Interfaces.GUI;
using LongoMatch.Core.Common;
using LongoMatch.Core.Store;
-using System.Collections.Generic;
-using LongoMatch.Core.Interfaces;
-using LongoMatch.Core.Store.Playlists;
-using LongoMatch.Core.Interfaces.Multimedia;
using LongoMatch.Gui.Helpers;
namespace LongoMatch.Gui
{
- [System.ComponentModel.Category("LongoMatch")]
- [System.ComponentModel.ToolboxItem(true)]
- public partial class PlayerCapturerBin : Gtk.Bin, IPlayerBin, ICapturerBin
- {
+ [System.ComponentModel.Category ("LongoMatch")]
+ [System.ComponentModel.ToolboxItem (true)]
+ public partial class PlayerCapturerBin : Gtk.Bin
+ {
/* Player Events */
public event StateChangeHandler PlayStateChanged;
-
- public enum PlayerOperationMode {
+
+ public enum PlayerOperationMode
+ {
Player,
Capturer,
FakeCapturer,
PreviewCapturer,
}
-
+
PlayerOperationMode mode;
bool backLoaded = false;
-
+
public PlayerCapturerBin ()
{
this.Build ();
- ConnectSignals();
+ ConnectSignals ();
replayhbox.HeightRequest = livebox.HeightRequest =
StyleConf.PlayerCapturerControlsHeight;
replayimage.Pixbuf = Misc.LoadIcon ("longomatch-replay",
StyleConf.PlayerCapturerIconSize);
liveimage.Pixbuf = Misc.LoadIcon ("longomatch-live",
StyleConf.PlayerCapturerIconSize);
@@ -57,6 +54,7 @@ namespace LongoMatch.Gui
replaylabel.ModifyFg (Gtk.StateType.Normal, Misc.ToGdkColor
(Config.Style.PaletteActive));
livebox.Visible = replayhbox.Visible = false;
playerbin.CloseEvent += HandleCloseClicked;
+ playerbin.PrepareLoadEvent += HandlePrepareLoadEvent;
}
protected override void OnDestroyed ()
@@ -65,22 +63,28 @@ namespace LongoMatch.Gui
capturerbin.Destroy ();
base.OnDestroyed ();
}
-
+
public IPlayerBin Player {
get {
return playerbin;
}
}
-
+
+ public ICapturerBin Capturer {
+ get {
+ return capturerbin;
+ }
+ }
+
public PlayerOperationMode Mode {
set {
mode = value;
if (mode == PlayerOperationMode.Player) {
- ShowPlayer();
+ ShowPlayer ();
playerbin.Compact = false;
playerbin.CloseAlwaysVisible = false;
} else {
- ShowCapturer();
+ ShowCapturer ();
playerbin.CloseAlwaysVisible = true;
playerbin.Compact = true;
}
@@ -88,8 +92,9 @@ namespace LongoMatch.Gui
backLoaded = false;
}
}
-
- public void ShowPlayer () {
+
+ public void ShowPlayer ()
+ {
playerbox.Visible = true;
replayhbox.Visible = false;
if (mode == PlayerOperationMode.PreviewCapturer && Config.ReviewPlaysInSameWindow)
@@ -97,8 +102,9 @@ namespace LongoMatch.Gui
else
capturerbox.Visible = false;
}
-
- public void ShowCapturer () {
+
+ public void ShowCapturer ()
+ {
playerbox.Visible = false;
livebox.Visible = false;
capturerbox.Visible = true;
@@ -113,237 +119,42 @@ namespace LongoMatch.Gui
playerbin.Pause ();
ShowCapturer ();
}
-
-#region Common
- public void Close () {
- playerbin.Close ();
- capturerbin.Close ();
- }
-
-#endregion
-
-#region Capturer
- public ICapturer Capturer {
- get {
- return capturerbin.Capturer;
- }
- }
+ #region Common
- public Time CurrentCaptureTime {
- get {
- return capturerbin.CurrentCaptureTime;
- }
- }
-
- public Image CurrentCaptureFrame {
- get {
- return capturerbin.CurrentCaptureFrame;
- }
- }
-
- public CaptureSettings CaptureSettings {
- get {
- return capturerbin.CaptureSettings;
- }
- }
-
- public bool Capturing {
- get {
- return capturerbin.Capturing;
- }
- }
-
- public List<string> PeriodsNames {
- set {
- capturerbin.PeriodsNames = value;
- }
- }
-
- public List<Period> Periods {
- get {
- return capturerbin.Periods;
- }
- set {
- capturerbin.Periods = value;
- }
- }
-
- public void StartPeriod () {
- capturerbin.StartPeriod ();
- }
-
- public void StopPeriod () {
- capturerbin.StopPeriod ();
- }
-
- public void Run (CaptureSettings settings, MediaFile outputFile) {
- capturerbin.Run (settings, outputFile);
- }
-
- public void PausePeriod ()
+ public void Close ()
{
- capturerbin.PausePeriod ();
- }
-
- public void ResumePeriod ()
- {
- capturerbin.ResumePeriod ();
- }
-
-#endregion
-
-
-#region Player
-
- public Time CurrentTime {
- get {
- return playerbin.CurrentTime;
- }
- }
-
- public bool Playing {
- get {
- return playerbin.Playing;
- }
- }
-
- public object CamerasLayout {
- get {
- return playerbin.CamerasLayout;
- }
+ playerbin.Close ();
+ capturerbin.Close ();
}
- public List<int> CamerasVisible {
- get {
- return playerbin.CamerasVisible;
- }
- }
+ #endregion
- public bool SeekingEnabled {
- set {
- playerbin.SeekingEnabled = value;
- }
- }
-
- public Time StreamLength {
- get {
- return playerbin.StreamLength;
- }
- }
-
- public Image CurrentFrame {
- get {
- return playerbin.CurrentFrame;
- }
- }
-
- public Image CurrentMiniatureFrame {
- get {
- return playerbin.CurrentMiniatureFrame;
- }
- }
-
- public bool Opened {
- get {
- return playerbin.Opened;
- }
- }
-
- public bool FullScreen {
- set {
- playerbin.FullScreen = value;
- }
- }
-
- public void Open (MediaFileSet fileSet) {
- playerbin.Open (fileSet);
- }
-
- public void Play () {
- playerbin.Play ();
- }
-
- public void Pause () {
- playerbin.Pause ();
- }
-
- public void TogglePlay () {
- playerbin.TogglePlay ();
- }
-
- public void ResetGui () {
- playerbin.ResetGui ();
- }
-
- public void LoadPlayListPlay (Playlist playlist, IPlaylistElement play) {
- playerbin.LoadPlayListPlay (playlist, play);
- }
-
- public void LoadPlay (MediaFileSet fileSet, TimelineEvent play, Time seekTime, bool playing) {
+ void HandlePrepareLoadEvent (MediaFileSet fileSet)
+ {
if (mode == PlayerOperationMode.PreviewCapturer) {
ShowPlayer ();
- LoadBackgroundPlayer(fileSet);
+ LoadBackgroundPlayer (fileSet);
livebox.Visible = replayhbox.Visible = true;
}
- playerbin.LoadPlay (fileSet, play, seekTime, playing);
- }
-
- public void Seek (Time time, bool accurate) {
- playerbin.Seek (time, accurate);
- }
-
- public void SeekToNextFrame () {
- playerbin.SeekToNextFrame ();
}
-
- public void SeekToPreviousFrame () {
- playerbin.SeekToPreviousFrame ();
- }
-
- public void StepForward () {
- playerbin.StepForward ();
- }
-
- public void StepBackward () {
- playerbin.StepBackward ();
- }
-
- public void FramerateUp () {
- playerbin.FramerateUp ();
- }
-
- public void FramerateDown () {
- playerbin.FramerateDown ();
- }
-
- public void CloseSegment () {
- playerbin.CloseSegment ();
- }
-
- public void SetSensitive () {
- playerbin.SetSensitive ();
- }
-
- public void UnSensitive () {
- playerbin.UnSensitive ();
- }
-#endregion
protected void OnBacktolivebuttonClicked (object sender, System.EventArgs e)
{
- playerbin.Pause();
+ playerbin.Pause ();
ShowCapturer ();
}
-
- void ConnectSignals () {
+
+ void ConnectSignals ()
+ {
playerbin.PlayStateChanged += delegate (bool playing) {
if (PlayStateChanged != null)
PlayStateChanged (playing);
};
}
-
- void LoadBackgroundPlayer (MediaFileSet file) {
+
+ void LoadBackgroundPlayer (MediaFileSet file)
+ {
if (backLoaded)
return;
diff --git a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
index ab3ec3d..bf779b8 100644
--- a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
@@ -48,13 +48,13 @@ namespace LongoMatch.Gui.Component
public IPlayerBin Player {
get {
- return playercapturer;
+ return playercapturer.Player;
}
}
public ICapturerBin Capturer {
get {
- return playercapturer;
+ return playercapturer.Capturer;
}
}
@@ -122,11 +122,11 @@ namespace LongoMatch.Gui.Component
public void DetachPlayer ()
{
- bool isPlaying = playercapturer.Playing;
+ bool isPlaying = Player.Playing;
/* Pause the player here to prevent the sink drawing while the windows
* are beeing changed */
- playercapturer.Pause ();
+ Player.Pause ();
if (!detachedPlayer) {
Log.Debug ("Detaching player");
@@ -149,7 +149,7 @@ namespace LongoMatch.Gui.Component
playerWindow.Destroy ();
}
if (isPlaying) {
- playercapturer.Play ();
+ Player.Play ();
}
detachedPlayer = !detachedPlayer;
}
@@ -178,8 +178,8 @@ namespace LongoMatch.Gui.Component
} else {
playercapturer.Mode =
PlayerCapturerBin.PlayerOperationMode.PreviewCapturer;
}
- playercapturer.PeriodsNames = project.Dashboard.GamePeriods;
- playercapturer.Periods = project.Periods;
+ Capturer.PeriodsNames = project.Dashboard.GamePeriods;
+ Capturer.Periods = project.Periods;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]