mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
278e05cbf3
External and internal audio players work similarly now. Fixes #950. * inherit a new ExternalAudioPlayer class from AudioPlayerInterface; * use an existing ExternalViewer class to implement ExternalAudioPlayer; * take (const char *, int) instead of std::vector<char> in ExternalViewer constructor to fit into AudioPlayerInterface; * extend ExternalViewer API to let ExternalAudioPlayer stop superseded audio player processes; * make AudioPlayerInterface::play() return an error message string to allow reporting immediate failures from derived classes; * Document AudioPlayerInterface API; * Document AudioPlayerFactory::player(); * use the common audio interface exclusively in ArticleView.
42 lines
829 B
C++
42 lines
829 B
C++
/* This file is (c) 2018 Igor Kushnir <igorkuo@gmail.com>
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
#ifndef FFMPEGAUDIOPLAYER_HH_INCLUDED
|
|
#define FFMPEGAUDIOPLAYER_HH_INCLUDED
|
|
|
|
#include "audioplayerinterface.hh"
|
|
#include "ffmpegaudio.hh"
|
|
|
|
#ifndef DISABLE_INTERNAL_PLAYER
|
|
|
|
namespace Ffmpeg
|
|
{
|
|
|
|
class AudioPlayer : public AudioPlayerInterface
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
AudioPlayer()
|
|
{
|
|
connect( &AudioService::instance(), SIGNAL( error( QString ) ),
|
|
this, SIGNAL( error( QString ) ) );
|
|
}
|
|
|
|
virtual QString play( const char * data, int size )
|
|
{
|
|
AudioService::instance().playMemory( data, size );
|
|
return QString();
|
|
}
|
|
|
|
virtual void stop()
|
|
{
|
|
AudioService::instance().stop();
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif // DISABLE_INTERNAL_PLAYER
|
|
|
|
#endif // FFMPEGAUDIOPLAYER_HH_INCLUDED
|