1 /* This file is (c) 2018 Igor Kushnir <igorkuo@gmail.com>
2  * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
3 
4 #ifndef AUDIOPLAYERFACTORY_HH_INCLUDED
5 #define AUDIOPLAYERFACTORY_HH_INCLUDED
6 
7 #include "audioplayerinterface.hh"
8 #include "config.hh"
9 
10 class ExternalAudioPlayer;
11 
12 class AudioPlayerFactory
13 {
14   Q_DISABLE_COPY( AudioPlayerFactory )
15 public:
16   explicit AudioPlayerFactory( Config::Preferences const & );
17   void setPreferences( Config::Preferences const & );
18   /// The returned reference to a smart pointer is valid as long as this object
19   /// exists. The pointer to the owned AudioPlayerInterface may change after the
20   /// call to setPreferences(), but it is guaranteed to never be null.
player() const21   AudioPlayerPtr const & player() const { return playerPtr; }
22 
23 private:
24   void reset();
25   void setAudioPlaybackProgram( ExternalAudioPlayer & externalPlayer );
26 
27   bool useInternalPlayer;
28   Config::InternalPlayerBackend internalPlayerBackend;
29   QString audioPlaybackProgram;
30   AudioPlayerPtr playerPtr;
31 };
32 
33 #endif // AUDIOPLAYERFACTORY_HH_INCLUDED
34