Skip to content

Commit

Permalink
Add the "Ignore video beginnings" option (beta)
Browse files Browse the repository at this point in the history
  • Loading branch information
yfdyh000 committed Apr 5, 2022
1 parent f07d1d6 commit dc8d21c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions PhotoSift/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ public Color CustomMenuColorHightlight
public bool ZoomLimitMaxToWindowSize { get; set; }
[Category("Controls"), DisplayName("Player intercept keys"), DescriptionAttribute("If enabled, the video player will intercept some keyboard keys to perform actions.")]
public VideoPlayerHookKeysOptions VideoPlayerHookKeysControl { get; set; }
[Category("Controls"), DisplayName("Ignore video beginnings"), DescriptionAttribute("If the value is greater than 0, the videos will be seek to the location (in seconds) to ignore the beginning. If the video length is less than this value, it plays from scratch. Seeking is not supported for some video formats.")]
public int SkipVideoBeginSeconds { get; set; }

// Display Group
[Category( "Display" ), DisplayName( "Info label" ), DescriptionAttribute( "Info label is the one in the top left corner. It shows information about the currently loaded image. In windowed mode, this information is also shown in the window title." )]
Expand Down Expand Up @@ -489,6 +491,7 @@ public AppSettings()
defaultSettings.Add("ZoomSteps", "5,10,25,50,75,100,125,150,175,200");
defaultSettings.Add("ZoomLimitMaxToWindowSize", false);
defaultSettings.Add("VideoPlayerHookKeysControl", VideoPlayerHookKeysOptions.Basic);
defaultSettings.Add("SkipVideoBeginSeconds", 0);

// Display Group
defaultSettings.Add("ShowInfoLabel", ShowModes.FullscreenOnly);
Expand Down
15 changes: 14 additions & 1 deletion PhotoSift/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public partial class frmMain : Form
private bool bCursorVisible = true;
private int FullScreenCursorLastMouseX = -1;
private bool bPreventAutoHideCursor = false;
private bool bNewVideoPlaying = false;

private string[] allowsMIME;

Expand Down Expand Up @@ -377,7 +378,7 @@ private string getMetaInfo(bool isVideo, bool mediaLoaded)
sb.Replace("%f", System.IO.Path.GetFileName(pics[iCurrentPic]));
sb.Replace("%p", System.IO.Path.GetDirectoryName(pics[iCurrentPic]));
sb.Replace("%d", System.IO.Directory.GetParent(pics[iCurrentPic]).Name);
sb.Replace("%w", wmpCurrent.currentMedia.imageSourceWidth.ToString());
sb.Replace("%w", wmpCurrent.currentMedia.imageSourceWidth.ToString()); // need wmppsPlaying, not work for 'wmppsReady'
sb.Replace("%h", wmpCurrent.currentMedia.imageSourceHeight.ToString());
sb.Replace("%n", "\n");
sb.Replace("%c", (iCurrentPic + 1).ToString());
Expand Down Expand Up @@ -492,6 +493,7 @@ private void ShowPicByOffset( int picsToSkip, ShowPicMode specialMode = ShowPicM
}
else
{
bNewVideoPlaying = true;
wmpCurrent.URL = URI;
}

Expand Down Expand Up @@ -1502,6 +1504,17 @@ private void wmpCurrent_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_Pl
{
this.Text = getMetaInfo(true, true);
lblInfoLabel.Text = this.Text;
if (bNewVideoPlaying) {
if (settings.SkipVideoBeginSeconds > 0 &&
wmpCurrent.Ctlcontrols.currentPosition < settings.SkipVideoBeginSeconds &&
wmpCurrent.currentMedia.duration > settings.SkipVideoBeginSeconds)
{
wmpCurrent.Ctlcontrols.pause();
wmpCurrent.Ctlcontrols.currentPosition = settings.SkipVideoBeginSeconds;
wmpCurrent.Ctlcontrols.play();
}
bNewVideoPlaying = false;
}
}
}

Expand Down

0 comments on commit dc8d21c

Please sign in to comment.