UI: Added shortcuts to start/stop recording video/audio/movies
This commit is contained in:
parent
d8b91efd65
commit
42015e9f8c
11 changed files with 95 additions and 13 deletions
|
@ -48,11 +48,7 @@ void MovieManager::Play(VirtualFile file, bool forTest)
|
||||||
void MovieManager::Stop()
|
void MovieManager::Stop()
|
||||||
{
|
{
|
||||||
_player.reset();
|
_player.reset();
|
||||||
|
_recorder.reset();
|
||||||
if(_recorder) {
|
|
||||||
_recorder->Stop();
|
|
||||||
_recorder.reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MovieManager::Playing()
|
bool MovieManager::Playing()
|
||||||
|
|
|
@ -25,6 +25,7 @@ MovieRecorder::MovieRecorder(shared_ptr<Console> console)
|
||||||
|
|
||||||
MovieRecorder::~MovieRecorder()
|
MovieRecorder::~MovieRecorder()
|
||||||
{
|
{
|
||||||
|
Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MovieRecorder::Record(RecordMovieOptions options)
|
bool MovieRecorder::Record(RecordMovieOptions options)
|
||||||
|
|
|
@ -373,6 +373,10 @@ enum class EmulatorShortcut
|
||||||
// Everything below this is handled UI-side
|
// Everything below this is handled UI-side
|
||||||
TakeScreenshot,
|
TakeScreenshot,
|
||||||
|
|
||||||
|
ToggleRecordVideo,
|
||||||
|
ToggleRecordAudio,
|
||||||
|
ToggleRecordMovie,
|
||||||
|
|
||||||
IncreaseSpeed,
|
IncreaseSpeed,
|
||||||
DecreaseSpeed,
|
DecreaseSpeed,
|
||||||
MaxSpeed,
|
MaxSpeed,
|
||||||
|
|
|
@ -116,7 +116,6 @@ void VideoRenderer::StopRecording()
|
||||||
{
|
{
|
||||||
shared_ptr<IVideoRecorder> recorder = _recorder;
|
shared_ptr<IVideoRecorder> recorder = _recorder;
|
||||||
if(recorder) {
|
if(recorder) {
|
||||||
recorder->StopRecording();
|
|
||||||
MessageManager::DisplayMessage("VideoRecorder", "VideoRecorderStopped", recorder->GetOutputFile());
|
MessageManager::DisplayMessage("VideoRecorder", "VideoRecorderStopped", recorder->GetOutputFile());
|
||||||
}
|
}
|
||||||
_recorder.reset();
|
_recorder.reset();
|
||||||
|
|
|
@ -9,9 +9,11 @@ WaveRecorder::WaveRecorder(string outputFile, uint32_t sampleRate, bool isStereo
|
||||||
_streamSize = 0;
|
_streamSize = 0;
|
||||||
_sampleRate = sampleRate;
|
_sampleRate = sampleRate;
|
||||||
_isStereo = isStereo;
|
_isStereo = isStereo;
|
||||||
WriteHeader();
|
|
||||||
|
if(_stream) {
|
||||||
MessageManager::DisplayMessage("SoundRecorder", "SoundRecorderStarted", _outputFile);
|
WriteHeader();
|
||||||
|
MessageManager::DisplayMessage("SoundRecorder", "SoundRecorderStarted", _outputFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveRecorder::~WaveRecorder()
|
WaveRecorder::~WaveRecorder()
|
||||||
|
|
|
@ -8,8 +8,8 @@ namespace Mesen.GUI.Config
|
||||||
{
|
{
|
||||||
public class MovieRecordConfig
|
public class MovieRecordConfig
|
||||||
{
|
{
|
||||||
public RecordMovieFrom RecordFrom;
|
public RecordMovieFrom RecordFrom = RecordMovieFrom.CurrentState;
|
||||||
public string Author;
|
public string Author = "";
|
||||||
public string Description;
|
public string Description = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,10 @@ namespace Mesen.GUI.Config.Shortcuts
|
||||||
// Everything below this is handled UI-side
|
// Everything below this is handled UI-side
|
||||||
TakeScreenshot,
|
TakeScreenshot,
|
||||||
|
|
||||||
|
ToggleRecordVideo,
|
||||||
|
ToggleRecordAudio,
|
||||||
|
ToggleRecordMovie,
|
||||||
|
|
||||||
IncreaseSpeed,
|
IncreaseSpeed,
|
||||||
DecreaseSpeed,
|
DecreaseSpeed,
|
||||||
MaxSpeed,
|
MaxSpeed,
|
||||||
|
|
|
@ -787,6 +787,10 @@
|
||||||
<Message ID="EmulatorShortcutMappings_ToggleSprites">Toggle Sprites</Message>
|
<Message ID="EmulatorShortcutMappings_ToggleSprites">Toggle Sprites</Message>
|
||||||
<Message ID="EmulatorShortcutMappings_EnableAllLayers">Enable All Layers</Message>
|
<Message ID="EmulatorShortcutMappings_EnableAllLayers">Enable All Layers</Message>
|
||||||
|
|
||||||
|
<Message ID="EmulatorShortcutMappings_ToggleRecordVideo">Start/Stop Recording Video</Message>
|
||||||
|
<Message ID="EmulatorShortcutMappings_ToggleRecordAudio">Start/Stop Recording Audio</Message>
|
||||||
|
<Message ID="EmulatorShortcutMappings_ToggleRecordMovie">Start/Stop Recording Movie</Message>
|
||||||
|
|
||||||
<Message ID="EmulatorShortcutMappings_MaxSpeed">Toggle Maximum Speed</Message>
|
<Message ID="EmulatorShortcutMappings_MaxSpeed">Toggle Maximum Speed</Message>
|
||||||
<Message ID="EmulatorShortcutMappings_LoadRandomGame">Load Random Game</Message>
|
<Message ID="EmulatorShortcutMappings_LoadRandomGame">Load Random Game</Message>
|
||||||
<Message ID="EmulatorShortcutMappings_SaveStateSlot1">Save State - Slot 1</Message>
|
<Message ID="EmulatorShortcutMappings_SaveStateSlot1">Save State - Slot 1</Message>
|
||||||
|
|
|
@ -97,6 +97,8 @@ namespace Mesen.GUI.Emulation
|
||||||
LoadPatchFile(filename);
|
LoadPatchFile(filename);
|
||||||
} else if(Path.GetExtension(filename).ToLowerInvariant() == ".mss") {
|
} else if(Path.GetExtension(filename).ToLowerInvariant() == ".mss") {
|
||||||
EmuApi.LoadStateFile(filename);
|
EmuApi.LoadStateFile(filename);
|
||||||
|
} else if(IsRunning() && Path.GetExtension(filename).ToLowerInvariant() == ".msm") {
|
||||||
|
RecordApi.MoviePlay(filename);
|
||||||
} else {
|
} else {
|
||||||
LoadRom(filename);
|
LoadRom(filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,10 @@ namespace Mesen.GUI.Emulation
|
||||||
case EmulatorShortcut.ToggleSprites: ToggleSprites(); break;
|
case EmulatorShortcut.ToggleSprites: ToggleSprites(); break;
|
||||||
case EmulatorShortcut.EnableAllLayers: EnableAllLayers(); break;
|
case EmulatorShortcut.EnableAllLayers: EnableAllLayers(); break;
|
||||||
|
|
||||||
|
case EmulatorShortcut.ToggleRecordVideo: ToggleRecordVideo(); break;
|
||||||
|
case EmulatorShortcut.ToggleRecordAudio: ToggleRecordAudio(); break;
|
||||||
|
case EmulatorShortcut.ToggleRecordMovie: ToggleRecordMovie(); break;
|
||||||
|
|
||||||
case EmulatorShortcut.TakeScreenshot: EmuApi.TakeScreenshot(); break;
|
case EmulatorShortcut.TakeScreenshot: EmuApi.TakeScreenshot(); break;
|
||||||
|
|
||||||
case EmulatorShortcut.LoadStateFromFile: SaveStateManager.LoadStateFromFile(); break;
|
case EmulatorShortcut.LoadStateFromFile: SaveStateManager.LoadStateFromFile(); break;
|
||||||
|
@ -162,7 +166,69 @@ namespace Mesen.GUI.Emulation
|
||||||
_displayManager.SetFullscreenState(true);
|
_displayManager.SetFullscreenState(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ToggleRecordVideo()
|
||||||
|
{
|
||||||
|
if(!EmuApi.IsRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RecordApi.AviIsRecording()) {
|
||||||
|
RecordApi.AviStop();
|
||||||
|
} else {
|
||||||
|
string filename = GetOutputFilename(ConfigManager.AviFolder, ConfigManager.Config.AviRecord.Codec == VideoCodec.GIF ? ".gif" : ".avi");
|
||||||
|
RecordApi.AviRecord(filename, ConfigManager.Config.AviRecord.Codec, ConfigManager.Config.AviRecord.CompressionLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ToggleRecordAudio()
|
||||||
|
{
|
||||||
|
if(!EmuApi.IsRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RecordApi.WaveIsRecording()) {
|
||||||
|
RecordApi.WaveStop();
|
||||||
|
} else {
|
||||||
|
string filename = GetOutputFilename(ConfigManager.WaveFolder, ".wav");
|
||||||
|
RecordApi.WaveRecord(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ToggleRecordMovie()
|
||||||
|
{
|
||||||
|
if(!EmuApi.IsRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!RecordApi.MoviePlaying() && !NetplayApi.IsConnected()) {
|
||||||
|
if(RecordApi.MovieRecording()) {
|
||||||
|
RecordApi.MovieStop();
|
||||||
|
} else {
|
||||||
|
RecordMovieOptions options = new RecordMovieOptions(
|
||||||
|
GetOutputFilename(ConfigManager.MovieFolder, ".msm"),
|
||||||
|
ConfigManager.Config.MovieRecord.Author,
|
||||||
|
ConfigManager.Config.MovieRecord.Description,
|
||||||
|
ConfigManager.Config.MovieRecord.RecordFrom
|
||||||
|
);
|
||||||
|
RecordApi.MovieRecord(ref options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetOutputFilename(string folder, string ext)
|
||||||
|
{
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
string baseName = EmuApi.GetRomInfo().GetRomName();
|
||||||
|
string dateTime = " " + now.ToShortDateString() + " " + now.ToLongTimeString();
|
||||||
|
string filename = baseName + dateTime + ext;
|
||||||
|
|
||||||
|
//Replace any illegal chars with _
|
||||||
|
filename = string.Join("_", filename.Split(Path.GetInvalidFileNameChars()));
|
||||||
|
|
||||||
|
return Path.Combine(folder, filename);
|
||||||
|
}
|
||||||
|
|
||||||
private void OpenFile()
|
private void OpenFile()
|
||||||
{
|
{
|
||||||
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
||||||
|
|
|
@ -48,6 +48,10 @@ namespace Mesen.GUI.Forms.Config
|
||||||
EmulatorShortcut.PowerOff,
|
EmulatorShortcut.PowerOff,
|
||||||
EmulatorShortcut.Exit,
|
EmulatorShortcut.Exit,
|
||||||
|
|
||||||
|
EmulatorShortcut.ToggleRecordVideo,
|
||||||
|
EmulatorShortcut.ToggleRecordAudio,
|
||||||
|
EmulatorShortcut.ToggleRecordMovie,
|
||||||
|
|
||||||
EmulatorShortcut.TakeScreenshot,
|
EmulatorShortcut.TakeScreenshot,
|
||||||
EmulatorShortcut.RunSingleFrame,
|
EmulatorShortcut.RunSingleFrame,
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue