Skip to content

Commit

Permalink
src v1.1.7.1
Browse files Browse the repository at this point in the history
- Fixed a bug where exported zip can have incorrect filename in some cases.
- Screen recorder somewhat complete?
- Updated greek localization file.
  • Loading branch information
rocksdanister committed Jan 9, 2021
1 parent eca2240 commit eb2f7f0
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Initialize(string filePath, Rect rect, int fps, int bitrate, bool is
libVLC = new LibVLC();
mediaPlayer = new MediaPlayer(libVLC);
media = new Media(libVLC, "screen://", FromType.FromLocation);
//When using non 16:9 resolutions capture is producing corrupted file?!
//IMP: When using non 16:9 resolutions capture is producing corrupted file?!
media.AddOption(":screen-left=" + (int)rect.Left);
media.AddOption(":screen-top=" + (int)rect.Top);
media.AddOption(":screen-width=" + (int)rect.Width);
Expand Down
2 changes: 1 addition & 1 deletion src/livelywpf/livelywpf/Properties/Resources.el.resx
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,6 @@ https://github.com/rocksdanister/lively/wiki</value>
<value>Πολιτική Απορρήτου</value>
</data>
<data name="TitleAudioDesktopOnly" xml:space="preserve">
<value>Play audio only when desktop is focused</value>
<value>Αναπαραγωγή ήχου μόνο όταν η επιφάνεια εργασίας είναι εστιασμένη</value>
</data>
</root>
3 changes: 2 additions & 1 deletion src/livelywpf/livelywpf/ViewModel/LibraryPreviewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ private void WInstance_CaptureProgress(object sender, double value)
{
Title = "Select location to save the file",
Filter = "Lively/zip file|*.zip",
FileName = libData.Title,
//title ending with '.' can have diff extension (example: parallax.js)
FileName = Path.ChangeExtension(libData.Title, ".zip"),
};
if (saveFileDialog1.ShowDialog() == true)
{
Expand Down
13 changes: 10 additions & 3 deletions src/livelywpf/livelywpf/ViewModel/LibraryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,16 @@ public async void WallpaperExport(object obj, string saveFile)
await Task.Run(() =>
{
try
{
if(selection.LivelyInfo.Type == WallpaperType.videostream
|| selection.LivelyInfo.Type == WallpaperType.url)
{
//title ending with '.' can have diff extension (example: parallax.js) or
//user made a custom filename with diff extension.
if (Path.GetExtension(saveFile) != ".zip")
{
saveFile += ".zip";
}

if (selection.LivelyInfo.Type == WallpaperType.videostream
|| selection.LivelyInfo.Type == WallpaperType.url)
{
//no wallpaper file on disk, only wallpaper metadata.
var tmpDir = Path.Combine(Program.AppDataDir, "temp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,45 @@ private void SetupDesktop_WallpaperInitialized(object sender, WindowInitializedA
//todo: INCOMPLETE: error/capture failure handling, auto library import after capture etc..
private void recordBtn_Click(object sender, RoutedEventArgs e)
{
if(!_recording)
if (!_recording)
{
_recording = true;
//save dialog
string savePath = "";
var saveFileDialog1 = new Microsoft.Win32.SaveFileDialog()
{
Title = "Select location to save the file",
Filter = Properties.Resources.TextVideo + "|*.mp4",
//title ending with '.' can have diff extension (example: parallax.js)
FileName = Path.ChangeExtension(wallpaperData.Title, ".mp4"),
};
if (saveFileDialog1.ShowDialog() == true)
{
savePath = saveFileDialog1.FileName;
}
if (string.IsNullOrEmpty(savePath))
{
return;
}
//overwrite existing file.
if (File.Exists(savePath))
{
try
{
File.Delete(savePath);
}
catch(Exception ex)
{
Logger.Error("Record status:Failed to delete existing file=>" + ex.Message);
return;
}
}

//recorder initialization
var item = WindowOperations.GetAbsolutePlacement(PreviewBorder, true);
recorder = new Helpers.ScreenRecorderDesktopDuplication();
recorder.Initialize(Path.Combine(@"J:\Test", "test.mp4"), item, 60, 8000 * 1000, false, false);
recorder.Initialize(savePath, item, 60, 8000 * 1000, false, false);
recorder.RecorderStatus += Recorder_RecorderStatus;
recorder.StartRecording();

//recording timer.
if(dispatcherTimer == null)
{
dispatcherTimer = new DispatcherTimer
Expand All @@ -230,27 +260,40 @@ private void recordBtn_Click(object sender, RoutedEventArgs e)
};
dispatcherTimer.Tick += DispatcherTimer_Tick;
}
elapsedTime = 0;
dispatcherTimer.Start();

//ui refresh.
//todo: mvvm rewrite.
recordBtn.ToolTip = null;
recordStatusText.Text = "0:00";
recordStatusGlyph.Foreground = new SolidColorBrush(Colors.Red);
StartRecording();
}
else
{
_recording = false;
dispatcherTimer?.Stop();
recorder?.StopRecording();

//ui refresh.
recordStatusText.Text = Properties.Resources.TextStart;
recordBtn.ToolTip = Properties.Resources.DescriptionRecordStart;
recordStatusGlyph.Foreground = new SolidColorBrush(Colors.Gray);
StopRecording();
}
}

private void StartRecording()
{

elapsedTime = 0;
_recording = true;
dispatcherTimer?.Start();
recorder?.StartRecording();

//ui refresh.
//todo: mvvm rewrite.
recordBtn.ToolTip = null;
recordStatusText.Text = "0:00";
recordStatusGlyph.Foreground = new SolidColorBrush(Colors.Red);
}

private void StopRecording()
{
_recording = false;
dispatcherTimer?.Stop();
recorder?.StopRecording();

//ui refresh
recordStatusText.Text = Properties.Resources.TextStart;
recordBtn.ToolTip = Properties.Resources.DescriptionRecordStart;
recordStatusGlyph.Foreground = new SolidColorBrush(Colors.Gray);
}

private void DispatcherTimer_Tick(object sender, EventArgs e)
{
Expand All @@ -271,6 +314,9 @@ private void Recorder_RecorderStatus(object sender, Helpers.ScreenRecorderStatus
case Helpers.ScreenRecorderStatus.paused:
break;
case Helpers.ScreenRecorderStatus.fail:
_ = this.Dispatcher.BeginInvoke(new Action(() => {
StopRecording();
}));
break;
case Helpers.ScreenRecorderStatus.recording:
break;
Expand Down
3 changes: 2 additions & 1 deletion src/livelywpf/livelywpf/Views/Main/LibraryView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ await this.Dispatcher.InvokeAsync(new Action(async () => {
{
Title = "Select location to save the file",
Filter = "Lively/zip file|*.zip",
FileName = ((LibraryModel)e).Title,
//title ending with '.' can have diff extension (example: parallax.js)
FileName = Path.ChangeExtension(((LibraryModel)e).Title, ".zip"),
};
if (saveFileDialog1.ShowDialog() == true)
{
Expand Down

0 comments on commit eb2f7f0

Please sign in to comment.