1.10
audio.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_AUDIO_H
7#define EGT_AUDIO_H
8
19#include <egt/detail/meta.h>
20#include <egt/object.h>
21#include <egt/signal.h>
22#include <memory>
23#include <string>
24
25namespace egt
26{
27inline namespace v1
28{
29
30namespace detail
31{
32class GstDecoderImpl;
33}
34
40class EGT_API AudioPlayer : public Object
41{
42protected:
43
45 std::unique_ptr<detail::GstDecoderImpl> m_impl;
46
47public:
48
57
62
67
75
80 explicit AudioPlayer(const std::string& uri);
81
82 AudioPlayer(const AudioPlayer&) = delete;
86
92 bool media(const std::string& uri);
93
98 bool play();
99
104 bool pause();
105
112 bool volume(int volume);
113
118 EGT_NODISCARD int volume() const;
119
126 bool mute(bool mute);
127
133 EGT_NODISCARD uint64_t position() const;
134
140 EGT_NODISCARD uint64_t duration() const;
141
151 bool seek(uint64_t pos);
152
156 EGT_NODISCARD bool playing() const;
157
158 ~AudioPlayer() noexcept override;
159};
160
161}
162}
163
164#endif
Audio player.
Definition audio.h:41
bool seek(uint64_t pos)
Seek to a position.
EGT_NODISCARD bool playing() const
Returns true if the stream is currently playing.
SignalW on_state_changed
Invoked when the state of the player changes.
Definition audio.h:71
bool play()
Send pipeline to play state.
bool mute(bool mute)
Mutes the audio being played.
bool volume(int volume)
Adjusts the volume of the audio being played.
bool pause()
pause Send Pipeline to pause state
EGT_NODISCARD int volume() const
Get the volume.
EGT_NODISCARD uint64_t position() const
Get the current position of the audio stream.
SignalW< const std::string & > on_error
Invoked when an error occurs.
Definition audio.h:61
std::unique_ptr< detail::GstDecoderImpl > m_impl
Implementation pointer.
Definition audio.h:45
SignalW< int64_t > on_position_changed
Event signal.
Definition audio.h:56
SignalW on_eos
Invoked on end of stream.
Definition audio.h:66
AudioPlayer(const AudioPlayer &)=delete
AudioPlayer(AudioPlayer &&)=default
AudioPlayer & operator=(const AudioPlayer &)=delete
AudioPlayer(const std::string &uri)
Construct and set the media file URI to the current pipeline.
AudioPlayer & operator=(AudioPlayer &&)=default
EGT_NODISCARD uint64_t duration() const
Get the duration of the audio stream.
~AudioPlayer() noexcept override
bool media(const std::string &uri)
Sets the media file URI to the current pipeline.
Base object class with fundamental properties.
Definition object.h:32
Definition signal.h:184
EGT framework namespace.
Definition animation.h:24