Add option to automatically open audio when opening video. Closes #1134.

Originally committed to SVN as r6224.
This commit is contained in:
Thomas Goyne 2012-01-08 01:33:47 +00:00
parent df9c6b627f
commit 02fa5bee3e
3 changed files with 20 additions and 3 deletions

View File

@ -541,6 +541,7 @@
},
"Pattern" : false
},
"Open Audio" : false,
"Overscan Mask" : false,
"Provider" : "ffmpegsource",
"Slider" : {

View File

@ -184,7 +184,7 @@ Video::Video(wxTreebook *book, Preferences *parent): OptionPage(book, parent, _(
OptionAdd(general, _("Show keyframes in slider"), "Video/Slider/Show Keyframes");
OptionAdd(general, _("Always show visual tools"), "Tool/Visual/Always Show");
OptionAdd(general, _("Seek video to line start on selection change"), "Video/Subtitle Sync");
CellSkip(general);
OptionAdd(general, _("Automatically open audio when opening video"), "Video/Open Audio");
const wxString czoom_arr[24] = { "12.5%", "25%", "37.5%", "50%", "62.5%", "75%", "87.5%", "100%", "112.5%", "125%", "137.5%", "150%", "162.5%", "175%", "187.5%", "200%", "212.5%", "225%", "237.5%", "250%", "262.5%", "275%", "287.5%", "300%" };
wxArrayString choice_zoom(24, czoom_arr);

View File

@ -48,6 +48,7 @@
#include <libaegisub/access.h>
#include <libaegisub/keyframe.h>
#include <libaegisub/log.h>
#include "ass_dialogue.h"
#include "ass_file.h"
@ -55,8 +56,6 @@
#include "ass_time.h"
#include "audio_controller.h"
#include "compat.h"
#include "include/aegisub/audio_player.h"
#include "include/aegisub/audio_provider.h"
#include "include/aegisub/context.h"
#include "include/aegisub/video_provider.h"
#include "main.h"
@ -207,6 +206,20 @@ void VideoContext::SetVideo(const wxString &filename) {
VideoOpen();
KeyframesOpen(keyFrames);
TimecodesOpen(FPS());
if (OPT_GET("Video/Open Audio")->GetBool()) {
try {
context->audioController->OpenAudio(filename);
}
// Opening a video with no audio data isn't an error, so just log
// and move on
catch (agi::FileNotAccessibleError const&) {
LOG_D("video/open/audio") << "File " << filename << " found by video provider but not audio provider";
}
catch (agi::AudioDataNotFoundError const& e) {
LOG_D("video/open/audio") << "File " << filename << " has no audio data: " << e.GetChainedMessage();
}
}
}
catch (agi::UserCancelException const&) { }
catch (agi::FileNotAccessibleError const& err) {
@ -216,6 +229,9 @@ void VideoContext::SetVideo(const wxString &filename) {
catch (VideoProviderError const& err) {
wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxICON_ERROR | wxOK);
}
catch (agi::AudioOpenError const& err) {
wxMessageBox(lagi_wxString(err.GetMessage()), "Error loading audio", wxICON_ERROR | wxOK);
}
}
void VideoContext::Reload() {