diff --git a/src/editor_state.cpp b/src/editor_state.cpp index ccf6663..618ec0b 100644 --- a/src/editor_state.cpp +++ b/src/editor_state.cpp @@ -1,5 +1,6 @@ #include "editor_state.hpp" +#include #include #include #include @@ -72,6 +73,7 @@ EditorState::EditorState( history.mark_as_saved(); reload_music(); reload_jacket(); + reload_preview_audio(); }; int EditorState::get_volume() const { @@ -110,6 +112,19 @@ void EditorState::speed_down() { set_speed(speed - 1); } +void EditorState::play_music_preview() { + if (song.metadata.use_preview_file) { + if (preview_audio) { + if (preview_audio->getStatus() == sf::Music::Playing) { + preview_audio->stop(); + } else { + preview_audio->stop(); + preview_audio->play(); + } + } + } +} + const Interval& EditorState::get_editable_range() { reload_editable_range(); @@ -530,6 +545,10 @@ void EditorState::display_file_properties() { ImGui::Separator(); ImGui::Text("Preview"); + if (ImGui::ArrowButton("Play", ImGuiDir_Right)) { + play_music_preview(); + } + ImGui::SameLine(); if (ImGui::Checkbox("Use separate preview file", &song.metadata.use_preview_file)) { if (song.metadata.use_preview_file) { history.push(std::make_shared(song.metadata.preview_loop, song.metadata.preview_file)); diff --git a/src/editor_state.hpp b/src/editor_state.hpp index 838bdd5..dc72f3b 100644 --- a/src/editor_state.hpp +++ b/src/editor_state.hpp @@ -72,6 +72,8 @@ public: std::optional preview_audio; + void play_music_preview(); + Playfield playfield; LinearView linear_view;