1#ifndef INLINE_AUDIO_PLAYER_H
2#define INLINE_AUDIO_PLAYER_H
5#include <QPropertyAnimation>
39 explicit
AudioPlayer(const QByteArray &audio_data, const QString &mime_type, QWidget *parent =
nullptr);
134 bool eventFilter(QObject *watched, QEvent *event)
override;
207 const auto spectrum_animation =
new QPropertyAnimation(
this,
"spectrumIntensity");
208 spectrum_animation->setDuration(600);
210 spectrum_animation->setEndValue(0.6);
211 spectrum_animation->setEasingCurve(QEasingCurve::OutCubic);
212 spectrum_animation->start(QPropertyAnimation::DeleteWhenStopped);
219 const auto spectrum_animation =
new QPropertyAnimation(
this,
"spectrumIntensity");
220 spectrum_animation->setDuration(800);
222 spectrum_animation->setEndValue(0.2);
223 spectrum_animation->setEasingCurve(QEasingCurve::OutCubic);
224 spectrum_animation->start(QPropertyAnimation::DeleteWhenStopped);
Decodes and plays audio data using FFmpeg libraries in a separate thread.
Definition audio_decoder.h:33
bool was_playing_
Stores whether playback was active before the user started dragging the slider.
Definition audio_player.h:276
void OnSliderPressed()
Slot called when the user presses the progress slider. Remembers the playback state and pauses playba...
Definition audio_player.cpp:296
void ToggleMute()
Toggles the mute state. If currently unmuted, mutes and remembers the last volume....
Definition audio_player.cpp:225
CyberAudioSlider * progress_slider_
Custom slider for displaying and seeking playback progress.
Definition audio_player.h:245
void PaintSpectrum(QWidget *target)
Custom painting method for the spectrum visualization widget. Draws a background grid and vertical ba...
Definition audio_player.cpp:452
double spectrum_intensity_
Intensity multiplier for the spectrum visualization (property).
Definition audio_player.h:283
void IncreaseSpectrumIntensity()
Starts an animation to increase the spectrum intensity (e.g., when playback starts).
Definition audio_player.h:206
static AudioPlayer * active_player_
Static pointer to the currently active InlineAudioPlayer instance. Ensures only one player uses audio...
Definition audio_player.h:288
QTimer * spectrum_timer_
Timer for triggering repaints of the spectrum view.
Definition audio_player.h:258
QLabel * audio_info_label_
Label displaying audio type, sample rate, channels.
Definition audio_player.h:237
void Deactivate()
Deactivates this player instance. Pauses playback if active, clears the global active player referenc...
Definition audio_player.cpp:195
QString mime_type_
Stores the MIME type of the audio data.
Definition audio_player.h:263
bool playback_finished_
Flag indicating if playback has reached the end.
Definition audio_player.h:274
void DecreaseSpectrumIntensity()
Starts an animation to decrease the spectrum intensity (e.g., when playback pauses or finishes).
Definition audio_player.h:218
std::shared_ptr< AudioDecoder > decoder_
Shared pointer to the AudioDecoder instance responsible for decoding and playback.
Definition audio_player.h:254
double spectrumIntensity
Property controlling the intensity/height of the spectrum visualization bars. Animatable.
Definition audio_player.h:27
double audio_duration_
Total duration of the audio in seconds. Set by HandleAudioInfo.
Definition audio_player.h:266
AudioPlayer(const QByteArray &audio_data, const QString &mime_type, QWidget *parent=nullptr)
Constructs an InlineAudioPlayer widget. Initializes UI elements (labels, buttons, sliders,...
Definition audio_player.cpp:16
void OnSliderReleased()
Slot called when the user releases the progress slider. Performs the actual seek operation based on t...
Definition audio_player.cpp:307
void HandleAudioInfo(int sample_rate, int channels, double duration)
Slot connected to the decoder's audioInfo signal. Stores the audio duration, sets the range for the p...
Definition audio_player.cpp:408
void Activate()
Activates this player instance. If another player is active, it deactivates it first....
Definition audio_player.cpp:168
TranslationManager * translator_
Pointer to the translation manager for handling UI text translations.
Definition audio_player.h:291
void paintEvent(QPaintEvent *event) override
Overridden paint event handler. Draws the cyberpunk-style frame border.
Definition audio_player.cpp:247
CyberAudioButton * volume_button_
Custom button for toggling mute. Icon changes based on volume.
Definition audio_player.h:249
bool slider_dragging_
Flag indicating if the user is currently dragging the progress slider.
Definition audio_player.h:270
void UpdateTimeLabel(int position)
Slot called when the progress slider's value changes (e.g., user dragging). Updates the time label di...
Definition audio_player.cpp:323
void SetSpectrumIntensity(const double intensity)
Sets the intensity multiplier for the spectrum visualization. Triggers an update() to repaint the spe...
Definition audio_player.h:68
void UpdateVolumeIcon(float volume) const
Updates the volume button icon based on the current volume level. Shows different icons for muted,...
Definition audio_player.cpp:237
void AdjustVolume(int volume) const
Adjusts the playback volume via the AudioDecoder. Also updates the volume icon based on the new volum...
Definition audio_player.cpp:216
double scanlineOpacity
Property controlling the opacity of a potential scanline effect.
Definition audio_player.h:25
void HandleError(const QString &message) const
Slot connected to the decoder's error signal. Prints the error message to debug output and updates th...
Definition audio_player.cpp:402
QByteArray m_audioData
Stores the raw audio data passed in the constructor.
Definition audio_player.h:261
CyberAudioButton * play_button_
Custom button for play/pause/replay control.
Definition audio_player.h:243
int last_volume_
Stores the volume level before muting.
Definition audio_player.h:272
double GetScanlineOpacity() const
Gets the current opacity value for the scanline effect.
Definition audio_player.h:45
void ReleaseResources()
Stops timers, stops and waits for the decoder thread, and releases decoder resources....
Definition audio_player.cpp:148
bool eventFilter(QObject *watched, QEvent *event) override
Overridden event filter. Intercepts paint events for the spectrum_view_ widget to call the custom Pai...
Definition audio_player.cpp:288
void UpdateUI()
Slot called periodically by ui_timer_. Updates UI elements, primarily the spectrum data for visualiza...
Definition audio_player.cpp:428
double GetSpectrumIntensity() const
Gets the current intensity multiplier for the spectrum visualization.
Definition audio_player.h:61
~AudioPlayer() override
Destructor. Ensures resources are released.
Definition audio_player.h:76
QLabel * status_label_
Label displaying playback status (Initializing, Ready, Playing, Paused, Error, Finished).
Definition audio_player.h:239
bool is_active_
Flag indicating if this player instance is the currently active one.
Definition audio_player.h:278
void SeekAudio(int position) const
Initiates a seek operation in the AudioDecoder. Converts the slider position (milliseconds) to second...
Definition audio_player.cpp:364
double current_position_
Current playback position in seconds. Updated by UpdateTimeLabel.
Definition audio_player.h:268
void SetScanlineOpacity(const double opacity)
Sets the opacity for the scanline effect. Triggers an update() to repaint the widget.
Definition audio_player.h:52
QWidget * spectrum_view_
Widget container where the spectrum visualization is drawn.
Definition audio_player.h:241
QTimer * ui_timer_
Timer for triggering periodic UI updates (e.g., spectrum data).
Definition audio_player.h:256
void UpdateSliderPosition(double position) const
Slot connected to the decoder's positionChanged signal. Updates the progress slider's position and th...
Definition audio_player.cpp:338
double scanline_opacity_
Opacity value for the scanline effect (property).
Definition audio_player.h:281
QLabel * time_label_
Label displaying current time / total duration (MM:SS / MM:SS).
Definition audio_player.h:247
void TogglePlayback()
Toggles the playback state (play/pause). Activates the player if necessary. Handles restarting playba...
Definition audio_player.cpp:372
CyberAudioSlider * volume_slider_
Custom slider for controlling playback volume.
Definition audio_player.h:251
QVector< double > spectrum_data_
Vector storing the current height values for the spectrum bars. Updated by UpdateUI.
Definition audio_player.h:285
A custom QSlider styled with a cyberpunk aesthetic, specifically themed for audio controls.
Definition cyber_audio_slider.h:13
Manages the loading and delivery of translations for applications.
Definition translation_manager.h:15