File indexing completed on 2024-12-08 09:42:39
0001 // Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com> 0002 // 0003 // Permission is hereby granted, free of charge, to any person obtaining a copy 0004 // of this software and associated documentation files (the "Software"), to deal 0005 // in the Software without restriction, including without limitation the rights 0006 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0007 // copies of the Software, and to permit persons to whom the Software is 0008 // furnished to do so, subject to the following conditions: 0009 // 0010 // The above copyright notice and this permission notice shall be included in 0011 // all copies or substantial portions of the Software. 0012 // 0013 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0014 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0015 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0016 // THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 0017 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 0018 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 0019 // 0020 // Except as contained in this notice, the name(s) of the author(s) shall not be 0021 // used in advertising or otherwise to promote the sale, use or other dealings 0022 // in this Software without prior written authorization from the author(s). 0023 0024 #include "player.h" 0025 #include "kmediaplayeradaptor_p.h" 0026 0027 class KMediaPlayer::PlayerPrivate 0028 { 0029 public: 0030 PlayerPrivate() 0031 : currentLooping(false) 0032 , currentState(Player::Empty) 0033 { 0034 if (!stateEnumRegistered) { 0035 stateEnumRegistered = qRegisterMetaType<KMediaPlayer::Player::State>("KMediaPlayer::Player::State"); 0036 } 0037 } 0038 0039 bool currentLooping; 0040 Player::State currentState; 0041 0042 static bool stateEnumRegistered; 0043 }; 0044 bool KMediaPlayer::PlayerPrivate::stateEnumRegistered = false; 0045 0046 KMediaPlayer::Player::Player(QWidget *, const char *, QObject *parent) 0047 : Player(parent) 0048 { 0049 } 0050 0051 KMediaPlayer::Player::Player(QObject *parent) 0052 : KParts::ReadOnlyPart(parent) 0053 , d(new PlayerPrivate()) 0054 { 0055 (void)new KMediaPlayerAdaptor(this); 0056 } 0057 0058 KMediaPlayer::Player::~Player() = default; 0059 0060 void KMediaPlayer::Player::setLooping(bool b) 0061 { 0062 if (b != d->currentLooping) { 0063 d->currentLooping = b; 0064 Q_EMIT loopingChanged(b); 0065 } 0066 } 0067 0068 bool KMediaPlayer::Player::isLooping() const 0069 { 0070 return d->currentLooping; 0071 } 0072 0073 void KMediaPlayer::Player::setState(State s) 0074 { 0075 if (s != d->currentState) { 0076 d->currentState = s; 0077 Q_EMIT stateChanged(s); 0078 } 0079 } 0080 0081 KMediaPlayer::Player::State KMediaPlayer::Player::state() const 0082 { 0083 return d->currentState; 0084 } 0085 0086 #include "moc_player.cpp"