KMediaPlayer

player.cpp
1 // Copyright (C) 2002 Neil Stevens <[email protected]>
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Except as contained in this notice, the name(s) of the author(s) shall not be
21 // used in advertising or otherwise to promote the sale, use or other dealings
22 // in this Software without prior written authorization from the author(s).
23 
24 #include "player.h"
25 #include "kmediaplayeradaptor_p.h"
26 
27 class KMediaPlayer::PlayerPrivate
28 {
29 public:
30  PlayerPrivate()
31  : currentLooping(false)
32  , currentState(Player::Empty)
33  {
34  if (!stateEnumRegistered) {
35  stateEnumRegistered = qRegisterMetaType<KMediaPlayer::Player::State>("KMediaPlayer::Player::State");
36  }
37  }
38 
39  bool currentLooping;
41 
42  static bool stateEnumRegistered;
43 };
44 bool KMediaPlayer::PlayerPrivate::stateEnumRegistered = false;
45 
46 KMediaPlayer::Player::Player(QWidget *, const char *, QObject *parent)
47  : Player(parent)
48 {
49 }
50 
52  : KParts::ReadOnlyPart(parent)
53  , d(new PlayerPrivate())
54 {
55  (void)new KMediaPlayerAdaptor(this);
56 }
57 
59 
61 {
62  if (b != d->currentLooping) {
63  d->currentLooping = b;
65  }
66 }
67 
69 {
70  return d->currentLooping;
71 }
72 
74 {
75  if (s != d->currentState) {
76  d->currentState = s;
78  }
79 }
80 
82 {
83  return d->currentState;
84 }
85 
void stateChanged(KMediaPlayer::Player::State newState)
Indicates that the value returned by state() has changed.
virtual ~Player()
Cleans up any associated resources.
State state() const
Returns the current state of the player.
bool isLooping() const
Returns whether playback will loop.
Definition: player.cpp:68
KOPENINGHOURS_EXPORT QString currentState(const OpeningHours &oh)
Player(QObject *parent)
Constructs a Player instance with no associated GUI.
Definition: player.cpp:51
void setState(State state)
Sets the current state.
Definition: player.cpp:73
void setLooping(bool on)
Sets whether playback should loop.
Definition: player.cpp:60
void loopingChanged(bool isLooping)
Indicates that the value of isLooping() has changed.
KPart interface to allow controlling and querying playback of a media track.
Definition: player.h:53
QObject * parent() const const
State
The possible states of the player.
Definition: player.h:204
Q_EMITQ_EMIT
ReadOnlyPart(QObject *parent=nullptr)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue May 11 2021 22:42:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.