2 #include <Process/ExecutionContext.hpp>
4 #include <Audio/AudioApplicationPlugin.hpp>
5 #include <Audio/AudioPreviewExecutor.hpp>
6 #include <Audio/Settings/Model.hpp>
7 #include <Engine/ApplicationPlugin.hpp>
8 #include <Library/LibraryInterface.hpp>
9 #include <Media/MediaFileHandle.hpp>
11 #include <score/tools/ThreadPool.hpp>
12 #include <score/widgets/MarginLess.hpp>
13 #include <score/widgets/Pixmap.hpp>
15 #include <ossia/audio/audio_protocol.hpp>
17 #include <ossia-qt/invoke.hpp>
20 #include <QHBoxLayout>
22 #include <QPushButton>
24 namespace Media::Sound
29 ,
public Nano::Observer
39 if(path.endsWith(
"rx2"))
44 lay->addWidget(&m_playstop);
45 lay->addWidget(&m_name);
46 m_name.setText(QFileInfo{path}.fileName());
47 m_reader.on_finishedDecoding.connect<&AudioPreviewWidget::on_finishedDecoding>(
49 m_reader.load({path, path, DecodingMethod::Libav});
51 m_playPixmap = score::get_pixmap(
":/icons/play_off.png");
52 m_stopPixmap = score::get_pixmap(
":/icons/stop_off.png");
54 m_playstop.setIcon(m_playPixmap);
56 m_playstop.setMinimumWidth(24);
57 m_playstop.setMaximumWidth(24);
59 connect(&m_playstop, &QPushButton::clicked,
this, [&]() {
73 void on_finishedDecoding()
77 m_playstop.setChecked(
false);
82 bool autoPlay()
const noexcept {
return m_autoPlay; }
83 void setAutoPlay(
bool b)
94 int rate = audio.getRate();
96 auto& inst = Audio::AudioPreviewExecutor::instance();
97 auto reader = m_reader.unsafe_handle().target<AudioFile::libav_ptr>();
99 SCORE_ASSERT((*reader)->handle);
100 inst.queue.enqueue({(*reader)->handle, (int)m_reader.channels(), (int)rate});
102 m_playstop.setIcon(m_stopPixmap);
107 auto& inst = Audio::AudioPreviewExecutor::instance();
108 inst.queue.enqueue({});
110 m_playstop.setIcon(m_playPixmap);
114 QPushButton m_playstop{
this};
116 QPixmap m_playPixmap;
117 QPixmap m_stopPixmap;
119 static inline bool m_autoPlay{
false};
124 SCORE_CONCRETE(
"7d735f7f-d474-404d-8984-ba627e12f08c")
126 QSet<QString> acceptedFiles()
const noexcept
override
128 return {
"wav",
"mp3",
"m4a",
"ogg",
"flac",
"aif",
129 "aiff",
"w64",
"ape",
"wv",
"wma"};
132 QWidget* previewWidget(
const QString& path, QWidget* parent)
const noexcept
override
Definition: score-plugin-audio/Audio/Settings/Model.hpp:22
Definition: LibraryInterface.hpp:22
T & settings() const
Access a specific Settings model instance.
Definition: ApplicationContext.hpp:40