Lumiera  0.pre.03
»edit your freedom«
playback-controller.cpp
Go to the documentation of this file.
1 /*
2  PlaybackController - playback controller object
3 
4  Copyright (C)
5  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
25 #include "lib/error.hpp"
26 #include "include/logging.h"
27 
28 
29 namespace stage {
30 namespace ctrl {
31 
32  namespace error = lumiera::error;
33 
34 
35 
36  PlaybackController::PlaybackController()
37  : playing_(false)
38  , viewerHandle_(0)
39  {
40  instance = this;
41  }
42 
43  PlaybackController::~PlaybackController()
44  {
45  instance = nullptr;
46  }
47 
48 
49  PlaybackController* PlaybackController::instance;
50 
51  PlaybackController&
52  PlaybackController::get()
53  {
54  if (not instance)
55  throw error::Logic ("GTK UI is not in running state"
56  , LERR_(LIFECYCLE));
57 
58  return *instance;
59  }
60 
61  void
62  PlaybackController::play()
63  {
64  if (playHandle_)
65  {
66  playHandle_.play(true);
67  playing_ = true;
68  }
69  else if (viewerHandle_)
70  try
71  {
72  playHandle_ = lumiera::DummyPlayer::facade().start (viewerHandle_);
73  playing_ = true;
74  }
75  catch (lumiera::error::State& err)
76  {
77  WARN (stage, "failed to start playback: %s" ,err.what());
78  lumiera_error();
79  playing_ = false;
80  }
81  }
82 
83  void
84  PlaybackController::pause()
85  {
86  if (playHandle_)
87  playHandle_.play(false);
88  playing_ = false;
89  }
90 
91  void
92  PlaybackController::stop()
93  {
94  playHandle_.close();
95  playing_ = false;
96  }
97 
98  bool
99  PlaybackController::is_playing()
100  {
101  return playing_;
102  }
103 
104 
105 
106  void
107  PlaybackController::useDisplay (LumieraDisplaySlot display)
108  {
109  viewerHandle_ = display;
110  }
111 
112 
113 }} // namespace stage::ctrl
114 
A public service provided by the GUI, implementing the lumiera::Display facade interface.
This header is for including and configuring NoBug.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
lumiera_err lumiera_error(void)
Get and clear current error state.
Definition: error-state.c:115
Lumiera error handling (C++ interface).
This file contains the definition of the playback controller object.
static lib::Depend< DummyPlayer > facade
get an implementation instance of this service