Skip to content

Commit

Permalink
Explicitly set the screenshot folder
Browse files Browse the repository at this point in the history
  • Loading branch information
BazzaCuda committed Apr 22, 2024
1 parent cec556d commit 51fde0e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
12 changes: 8 additions & 4 deletions mediaPlayer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ procedure TMediaPlayer.onInitMPV(sender: TObject);
setPropertyString('screenshot-png-compression', '0');
setPropertyString('screenshot-template', '%F %p %04n');
setPropertyString('sid', '1');
// setPropertyDouble('image-display-duration', 100);
setPropertyString('image-display-duration', 'inf');
// SetPropertyDouble('sub-delay', -00.99);
end;
end;
Expand Down Expand Up @@ -553,13 +553,16 @@ function TMediaPlayer.play(const aURL: string): boolean;
FMediaType := MT.mediaType(lowerCase(extractFileExt(PL.currentItem)));
// reset the window size for an audio file in case the previous file was a video, or the previous audio had an image but this one doesn't
case UI.autoCentre OR (FMediaType = mtAudio) of TRUE: UI.setWindowSize(FMediaType, MI.hasCoverArt); end;
case UI.autoCentre AND (FMediaType <> mtImage) of TRUE: postMessage(GV.appWND, WM_CENTRE_CURSOR, 0, 0); end;
UI.centreCursor;

openURL(aURL);
mpv.volume := FVol;
mpv.mute := FMuted;

FDontPlayNext := FMediaType = mtImage;
var vImageDisplayDuration: string;
mpv.getPropertyString('image-display-duration', vImageDisplayDuration, FALSE);

FDontPlayNext := (FMediaType = mtImage) and (vImageDisplayDuration = 'inf');

case ST.showData of TRUE: MI.getData(ST.dataMemo); end;
MC.caption := PL.formattedItem;
Expand All @@ -571,7 +574,7 @@ function TMediaPlayer.play(const aURL: string): boolean;
checkPot;

case assigned(FOnPlayNew) of TRUE: FOnPlayNew(SELF); end;
case UI.autoCentre AND (FMediaType <> mtImage) of TRUE: postMessage(GV.appWND, WM_CENTRE_CURSOR, 0, 0); end;
UI.centreCursor;

result := TRUE;
end;
Expand Down Expand Up @@ -773,6 +776,7 @@ function TMediaPlayer.tab(const aShiftState: TShiftState; const capsLock: boolea
function TMediaPlayer.takeScreenshot: string;
begin
case mpv = NIL of TRUE: EXIT; end;
mpv.setPropertyString('screenshot-directory', PL.currentFolder);
mpv.commandStr(CMD_SCREEN_SHOT);
result := '';
end;
Expand Down
6 changes: 6 additions & 0 deletions playlist.pas
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ TPlaylist = class(TObject)
function clear: boolean;
function count: integer;
function copyToClipboard: boolean;
function currentFolder: string;
function currentItem: string;
function currentIx: integer;
function delete(const ix: integer = -1): boolean;
Expand Down Expand Up @@ -106,6 +107,11 @@ constructor TPlaylist.create;
FPLaylist.sort;
end;

function TPlaylist.currentFolder: string;
begin
result := extractFilePath(currentItem);
end;

function TPlaylist.currentItem: string;
begin
result := '';
Expand Down
20 changes: 14 additions & 6 deletions uiCtrls.pas
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ TUI = class(TObject)
function adjustAspectRatio(const aWnd: HWND; const X: int64; const Y: int64): boolean;
function arrangeAll: boolean;
function autoCentreWindow(const aWnd: HWND): boolean;
function centreCursor: boolean;
function centreWindow(const aWnd: HWND): boolean;
function checkScreenLimits(const aWnd: HWND; const aWidth: integer; const aHeight: integer): boolean;
function deleteCurrentItem(const shift: TShiftState): boolean;
Expand All @@ -76,7 +77,7 @@ TUI = class(TObject)
function renameFile(const aFilePath: string): boolean;
function resize(const aWnd: HWND; const pt: TPoint; const X: int64; const Y: int64): boolean;
function showAboutBox: boolean;
function setWindowSize(const aMediaType: TMediaType; coverArt: boolean = FALSE): boolean;
function setWindowSize(const aMediaType: TMediaType; hasCoverArt: boolean = FALSE): boolean;
function showWindow: boolean;
function showXY: boolean;
function shutTimeline: boolean;
Expand Down Expand Up @@ -217,6 +218,11 @@ function TUI.autoCentreWindow(const aWnd: HWND): boolean;
centreWindow(aWnd);
end;

function TUI.centreCursor: boolean;
begin
case autoCentre AND (MP.MediaType <> mtImage) of TRUE: postMessage(GV.appWND, WM_CENTRE_CURSOR, 0, 0); end;
end;

function TUI.centreWindow(const aWnd: HWND): boolean;
var
vR: TRect;
Expand Down Expand Up @@ -456,6 +462,8 @@ function TUI.keepFile(const aFilePath: string): boolean;
function TUI.maximize: boolean;
begin
setWindowSize(mtVideo);
FAutoCentre := TRUE;
centreCursor;
end;

function TUI.minimizeWindow: boolean;
Expand Down Expand Up @@ -551,12 +559,12 @@ procedure TUI.setWidth(const Value: integer);
FMainForm.width := value;
end;

function TUI.setWindowSize(const aMediaType: TMediaType; coverArt: boolean = FALSE): boolean;
function TUI.setWindowSize(const aMediaType: TMediaType; hasCoverArt: boolean = FALSE): boolean;
begin
case aMediaType of mtAudio: begin case coverArt of TRUE: FMainForm.width := 600;
FALSE: FMainForm.width := 600; end;
case coverArt of FALSE: FMainForm.height := UI_DEFAULT_AUDIO_HEIGHT;
TRUE: FMainForm.height := 400; end;end;
case aMediaType of mtAudio: begin case hasCoverArt of TRUE: FMainForm.width := 600;
FALSE: FMainForm.width := 600; end;
case hasCoverArt of TRUE: FMainForm.height := 400;
FALSE: FMainForm.height := UI_DEFAULT_AUDIO_HEIGHT; end;end;
mtVideo: begin var vWidth := trunc((CU.getScreenHeight - 50) / CU.getAspectRatio(MI.X, MI.Y));
var VHeight := CU.getScreenHeight - 50;
SetWindowPos(FMainForm.Handle, HWND_TOP, (CU.getScreenWidth - vWidth) div 2, (CU.getScreenHeight - vHeight) div 2, vWidth, vHeight, SWP_NOSIZE); // center window
Expand Down

0 comments on commit 51fde0e

Please sign in to comment.