fix play music then changing tabs
This commit is contained in:
@@ -34,12 +34,12 @@ namespace monitor::components
|
|||||||
void audio::init(std::string snapshot_id, std::filesystem::path file)
|
void audio::init(std::string snapshot_id, std::filesystem::path file)
|
||||||
{
|
{
|
||||||
m_player.stop();
|
m_player.stop();
|
||||||
m_current_audio = music{ .m_id = snapshot_id, .m_current_time = sf::Time(), .m_file = file };
|
m_audio_data[snapshot_id] = music{ .m_id = snapshot_id, .m_current_time = sf::Time(), .m_file = file };
|
||||||
m_audio_data[snapshot_id] = m_current_audio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::change(std::string snapshot_id)
|
void audio::change(std::string snapshot_id)
|
||||||
{
|
{
|
||||||
|
hack::log()(m_current_audio.m_current_time.asSeconds());
|
||||||
m_audio_data[m_current_audio.m_id].m_current_time = m_current_audio.m_current_time;
|
m_audio_data[m_current_audio.m_id].m_current_time = m_current_audio.m_current_time;
|
||||||
m_player.stop();
|
m_player.stop();
|
||||||
m_current_audio = m_audio_data[snapshot_id];
|
m_current_audio = m_audio_data[snapshot_id];
|
||||||
@@ -51,7 +51,7 @@ namespace monitor::components
|
|||||||
{
|
{
|
||||||
m_current_audio.m_current_time = time;
|
m_current_audio.m_current_time = time;
|
||||||
// HERE
|
// HERE
|
||||||
// начинаем тут, делаем установку мсаркера проигрывания
|
// начинаем тут, делаем установку маркера проигрывания
|
||||||
VE::event e { utils::event_type::INCREMENT_MARKER_AUDIO_POSITION, pos };
|
VE::event e { utils::event_type::INCREMENT_MARKER_AUDIO_POSITION, pos };
|
||||||
EMIT(e);
|
EMIT(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,21 +27,15 @@ namespace monitor::components
|
|||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case utils::event_type::SET_AUDIO_STATUS:
|
case utils::event_type::INIT_AUDIO:
|
||||||
{
|
|
||||||
m_status = std::any_cast<utils::var::STATUS>(e.m_data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case utils::event_type::SET_AUDIO_FILE:
|
|
||||||
{
|
{
|
||||||
auto [snapshot_id, file] = std::any_cast<std::pair<std::string, std::filesystem::path>>(e.m_data);
|
auto [snapshot_id, file] = std::any_cast<std::pair<std::string, std::filesystem::path>>(e.m_data);
|
||||||
|
m_status = utils::var::STATUS::ACTIVE;
|
||||||
init(snapshot_id, file);
|
init(snapshot_id, file);
|
||||||
change(snapshot_id);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case utils::event_type::CHANGE_AUDIO_FILE:
|
case utils::event_type::CHANGE_AUDIO:
|
||||||
{
|
{
|
||||||
auto snapshot_id = std::any_cast<std::string>(e.m_data);
|
auto snapshot_id = std::any_cast<std::string>(e.m_data);
|
||||||
change(snapshot_id);
|
change(snapshot_id);
|
||||||
|
|||||||
@@ -33,10 +33,7 @@ namespace monitor::components
|
|||||||
m_setup = setup;
|
m_setup = setup;
|
||||||
m_base_plugins.init(m_snapshot_id, m_setup);
|
m_base_plugins.init(m_snapshot_id, m_setup);
|
||||||
|
|
||||||
VE::event e1 { utils::event_type::SET_AUDIO_STATUS, utils::var::STATUS::ACTIVE };
|
VE::event e { utils::event_type::INIT_AUDIO, std::pair<std::string, std::filesystem::path>(m_snapshot_id, setup.m_file) };
|
||||||
EMIT(e1);
|
EMIT(e);
|
||||||
|
|
||||||
VE::event e2 { utils::event_type::SET_AUDIO_FILE, std::pair<std::string, std::filesystem::path>(m_snapshot_id, setup.m_file) };
|
|
||||||
EMIT(e2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ namespace monitor::components
|
|||||||
|
|
||||||
VE::event e0 { utils::event_type::CREATE_SNAPSHOT_COMPLETED, nullptr };
|
VE::event e0 { utils::event_type::CREATE_SNAPSHOT_COMPLETED, nullptr };
|
||||||
EMIT(e0);
|
EMIT(e0);
|
||||||
m_current_open_index = m_snapshots.size() - 1 ;
|
|
||||||
|
change_tab(m_snapshots.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tabs::change_tab(std::size_t i)
|
void tabs::change_tab(std::size_t i)
|
||||||
@@ -40,7 +41,8 @@ namespace monitor::components
|
|||||||
m_snapshots[i]->set_status(utils::var::STATUS::ACTIVE);
|
m_snapshots[i]->set_status(utils::var::STATUS::ACTIVE);
|
||||||
m_current_open_index = i;
|
m_current_open_index = i;
|
||||||
|
|
||||||
VE::event e { utils::event_type::CHANGE_AUDIO_FILE, m_snapshots[i]->m_snapshot_id };
|
// send to: components/audio
|
||||||
|
VE::event e { utils::event_type::CHANGE_AUDIO, m_snapshots[i]->m_snapshot_id };
|
||||||
EMIT(e);
|
EMIT(e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace monitor::libs
|
|||||||
// сделать выбор устройства из интерфейса
|
// сделать выбор устройства из интерфейса
|
||||||
// поставь, то которое есть в списке устройств
|
// поставь, то которое есть в списке устройств
|
||||||
for (auto& d : devices) std::cout << d << std::endl;
|
for (auto& d : devices) std::cout << d << std::endl;
|
||||||
std::string target_device = devices[2];
|
std::string target_device = devices[1];
|
||||||
if (sf::PlaybackDevice::setDevice(target_device))
|
if (sf::PlaybackDevice::setDevice(target_device))
|
||||||
hack::log()("Устройство успешно установлено: ", target_device);
|
hack::log()("Устройство успешно установлено: ", target_device);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ namespace monitor::utils
|
|||||||
CREATE_SNAPSHOT_COMPLETED,
|
CREATE_SNAPSHOT_COMPLETED,
|
||||||
STATUS_PROCESS,
|
STATUS_PROCESS,
|
||||||
STATUS_COMPLETED,
|
STATUS_COMPLETED,
|
||||||
SET_AUDIO_STATUS,
|
INIT_AUDIO,
|
||||||
SET_AUDIO_FILE,
|
CHANGE_AUDIO,
|
||||||
CHANGE_AUDIO_FILE,
|
|
||||||
|
|
||||||
|
|
||||||
/// делать
|
/// делать
|
||||||
|
|||||||
Reference in New Issue
Block a user