TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SoundCore Class Reference

The SoundCore class provides a simple interface for audio playback. More...

#include <soundcore.h>

+ Inheritance diagram for SoundCore:

Public Slots

void setVolume (int left, int right)
 
void setMuted (bool mute)
 
void changeVolume (int delta)
 
void setVolume (int volume)
 
void volumeUp ()
 
void volumeDown ()
 
void setBalance (int balance)
 
bool play (const QString &source, bool queue=false, qint64 offset=-1)
 
void stop ()
 
void pause ()
 
void seek (qint64 time)
 
QString path () const
 

Signals

void bufferingProgress (int progress)
 
void elapsedChanged (qint64 time)
 
void bitrateChanged (int bitrate)
 
void audioParametersChanged (const AudioParameters &p)
 
void streamInfoChanged ()
 
void trackInfoChanged ()
 
void stateChanged (Qmmp::State newState)
 
void finished ()
 
void mutedChanged (bool muted)
 
void volumeChanged (int volume)
 
void balanceChanged (int balance)
 
void eqSettingsChanged ()
 
void nextTrackRequest ()
 

Public Member Functions

 SoundCore (QObject *parent=nullptr)
 
 ~SoundCore ()
 
qint64 duration () const
 
EqSettings eqSettings () const
 
void setEqSettings (const EqSettings &settings)
 
int leftVolume () const
 
int rightVolume () const
 
int volume () const
 
int balance () const
 
bool isMuted () const
 
qint64 elapsed () const
 
int bitrate () const
 
AudioParameters audioParameters () const
 
Qmmp::State state () const
 
const QMap< Qmmp::MetaData, QString > & metaData () const
 
QString metaData (Qmmp::MetaData key) const
 
const QHash< QString, QString > & streamInfo () const
 
const TrackInfotrackInfo () const
 
bool nextTrackAccepted () const
 

Static Public Member Functions

static SoundCoreinstance ()
 

Private Types

enum  NextEngineState { NO_ENGINE = 0, SAME_ENGINE, ANOTHER_ENGINE, INVALID_SOURCE }
 

Private Slots

void startNextSource ()
 
void startNextEngine ()
 

Private Member Functions

virtual bool event (QEvent *e) overridefinal
 

Private Attributes

QHash< QString, QString > m_streamInfo
 
TrackInfo m_info
 
QString m_path
 
StateHandlerm_handler = nullptr
 
VolumeHandlerm_volumeControl = nullptr
 
AbstractEnginem_engine = nullptr
 
QQueue< InputSource * > m_sources
 
int m_nextState = NO_ENGINE
 

Static Private Attributes

static SoundCorem_instance
 

Detailed Description

The SoundCore class provides a simple interface for audio playback.

Author
Ilya Kotov forko.nosp@m.tov0.nosp@m.2@ya..nosp@m.ru

Definition at line 40 of file soundcore.h.

Member Enumeration Documentation

Enumerator
NO_ENGINE 
SAME_ENGINE 
ANOTHER_ENGINE 
INVALID_SOURCE 

Definition at line 253 of file soundcore.h.

Constructor & Destructor Documentation

SoundCore::SoundCore ( QObject *  parent = nullptr)
explicit

Object constructor.

Parameters
parentParent object.
SoundCore::~SoundCore ( )

Destructor.

Member Function Documentation

AudioParameters SoundCore::audioParameters ( ) const

Returns output audio parameters.

void SoundCore::audioParametersChanged ( const AudioParameters p)
signal

Emitted when audio parameters have changed.

Parameters
pNew audio parameters for output.
int SoundCore::balance ( ) const

Returns the balance between left and right channels.

void SoundCore::balanceChanged ( int  balance)
signal

Emitted when the balance between left and right channels has changed.

Parameters
balancenew balance value.
int SoundCore::bitrate ( ) const

Returns current bitrate (in kbps)

void SoundCore::bitrateChanged ( int  bitrate)
signal

Emitted when bitrate has changed.

Parameters
bitrateNew bitrate (in kbps)
void SoundCore::bufferingProgress ( int  progress)
signal

This signal is emitted when the stream reader fills it's buffer. The argument progress indicates the current percentage of buffering completed.

void SoundCore::changeVolume ( int  delta)
slot

Changes volume by delta percent

qint64 SoundCore::duration ( ) const
qint64 SoundCore::elapsed ( ) const

Returns the current time (in milliseconds).

Referenced by MusicPlayer::position(), MusicMPRISPlayerCore::position(), and MusicMPRISPlayerCore::Seek().

void SoundCore::elapsedChanged ( qint64  time)
signal

Tracks elapesed time.

Parameters
timeNew track position in milliseconds.
EqSettings SoundCore::eqSettings ( ) const

Returns equalizer settings

Referenced by MusicPlayer::setEqualizerEffect().

void SoundCore::eqSettingsChanged ( )
signal

Emitted when equalizer settings has changed.

virtual bool SoundCore::event ( QEvent *  e)
finaloverrideprivatevirtual
void SoundCore::finished ( )
signal

Emitted when playback has finished.

static SoundCore* SoundCore::instance ( )
static
bool SoundCore::isMuted ( ) const

Returns true if volume is unmuted, otherwise returns false

Referenced by MusicPlayer::isMuted().

int SoundCore::leftVolume ( ) const

Returns left volume level.

const QMap<Qmmp::MetaData, QString>& SoundCore::metaData ( ) const

Returns all meta data in map.

QString SoundCore::metaData ( Qmmp::MetaData  key) const

Returns the metdata string associated with the given key.

void SoundCore::mutedChanged ( bool  muted)
signal

Emitted when volume has muted or restored

Parameters
mutednew state of the volume (true - muted, false - unmuted)
bool SoundCore::nextTrackAccepted ( ) const

Indicates that the current active engine will be used for the next queued track. May be useful for some effect plugins.

void SoundCore::nextTrackRequest ( )
signal

Emitted before playback ends. Use this signal to append new url to the queue.

QString SoundCore::path ( ) const
slot

This function returns file path or stream url.

Referenced by MusicSpectrumWidget::createLightWidget(), and MusicMPRISPlayerCore::metadata().

void SoundCore::pause ( )
slot

Pauses/resumes playback

Referenced by MusicPlayer::pause(), and MusicPlayer::play().

bool SoundCore::play ( const QString &  source,
bool  queue = false,
qint64  offset = -1 
)
slot

This function plays file or stream with the given path source. Returns true if playback has been started successful or source is not a local file, otherwise returns false. Useful for invalid files skipping.

Referenced by MusicPlayer::play().

int SoundCore::rightVolume ( ) const

Returns left volume level.

void SoundCore::seek ( qint64  time)
slot

This function sets the current play position to pos in milliseconds.

Referenced by MusicMPRISPlayerCore::Seek(), MusicPlayer::setPosition(), and MusicMPRISPlayerCore::SetPosition().

void SoundCore::setBalance ( int  balance)
slot

Sets the balance between left and right channels.

Parameters
balancebalance between left and right channels [-100..100].

Referenced by MusicPlayer::setEnhanced().

void SoundCore::setEqSettings ( const EqSettings settings)

Chages equalizer settings to settings.

Referenced by MusicPlayer::setEqualizerEffect().

void SoundCore::setMuted ( bool  mute)
slot

Mutes/Restores volume

Parameters
mute- state of volume (true - mute, false - restore)

Referenced by MusicPlayer::setMuted().

void SoundCore::setVolume ( int  left,
int  right 
)
slot

Sets volume.

Parameters
left- volume of the left channel [0..100].
right- volume of the right channel [0..100].

Referenced by MusicPlayer::setEnhanced(), MusicPlayer::setVolume(), and MusicPlayer::update().

void SoundCore::setVolume ( int  volume)
slot

Sets the volume of the left and right channels with keeping of the balance.

Parameters
volumevolume of the left and right channels [0..100].
void SoundCore::startNextEngine ( )
privateslot
void SoundCore::startNextSource ( )
privateslot
Qmmp::State SoundCore::state ( ) const
void SoundCore::stateChanged ( Qmmp::State  newState)
signal

This signal is emitted when the state of the SoundCore has changed.

void SoundCore::stop ( )
slot
const QHash<QString, QString>& SoundCore::streamInfo ( ) const

Returns a hash of stream information if available

void SoundCore::streamInfoChanged ( )
signal

Emitted when new stream information is available.

const TrackInfo& SoundCore::trackInfo ( ) const

Returns current track information.

Referenced by MusicMPRISPlayerCore::metadata(), and MusicQualityWidget::updateQuality().

void SoundCore::trackInfoChanged ( )
signal

Emitted when new track information is available.

int SoundCore::volume ( ) const

Returns the highest volume of the left and right channels.

Referenced by MusicPlayer::setMuted(), and MusicPlayer::volume().

void SoundCore::volumeChanged ( int  volume)
signal

Emitted when the highest volume of the left and right channels has changed.

Parameters
volumenew value of the highest volume of the left and right channels.
void SoundCore::volumeDown ( )
slot

Decreases volume by volume adjustment step.

void SoundCore::volumeUp ( )
slot

Increases volume by volume adjustment step.

Member Data Documentation

AbstractEngine* SoundCore::m_engine = nullptr
private

Definition at line 267 of file soundcore.h.

StateHandler* SoundCore::m_handler = nullptr
private

Definition at line 265 of file soundcore.h.

TrackInfo SoundCore::m_info
private

Definition at line 262 of file soundcore.h.

SoundCore* SoundCore::m_instance
staticprivate

Definition at line 264 of file soundcore.h.

int SoundCore::m_nextState = NO_ENGINE
private

Definition at line 269 of file soundcore.h.

QString SoundCore::m_path
private

Definition at line 263 of file soundcore.h.

QQueue<InputSource *> SoundCore::m_sources
private

Definition at line 268 of file soundcore.h.

QHash<QString, QString> SoundCore::m_streamInfo
private

Definition at line 261 of file soundcore.h.

VolumeHandler* SoundCore::m_volumeControl = nullptr
private

Definition at line 266 of file soundcore.h.


The documentation for this class was generated from the following file: