📜 ⬆️ ⬇️

Bookmarks in Media Player Classic Home Cinema

If you choose to keep history and save viewing positions in settings, MPC HC can automatically save up to 20 bookmarks to the last place to watch video files and the same number of bookmarks for DVD. When resuming viewing, the player will start playback from the last position if it finds information about the file in its database (it is stored together with other settings or in the registry or in the ini-file, depending on the user's choice). However, there are conditions when 20 bookmarks are not enough. Someone likes to watch many movies in parallel, sometimes postponing viewing for a while. Someone listens to music on MPC HC (and the keys for it are the same: one big album - and all the bookmarks are overwritten). Someone uses the player to test the encoded video repeatedly. Finally, several members of a family can use the same account (for example, children can watch cartoons while their parents are busy). In general, I would like to have a reliable way to save a bookmark on the desired movie and then restore it.

The registry data is stored in the section HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings . For video files, the File Name N / File Position N key pairs are used (c N from 0 to 19). For DVD, one DVD Position N key is used (in the same range; the player manages to save both the DVD ID and the last viewing place in one mysterious digital recording).

Three ways of creating custom bookmarks come to mind when working with the registry: from the simplest and least flexible to the more complex and subtle. Of course, the post does not claim to be rocket science. Simple and convenient practical tricks are described.
')

I. Export / import settings using the player itself




It is necessary to start the export after closing the player with the movie by launching MPC again, because only before closing the data on the latest files in the registry are updated. There is a .reg file with all the settings (and not only the section we need), and this is another disadvantage: when importing the settings, not only the desired tab will be restored, but the entire set of previous settings.

Let's try to improve the situation a bit (further solutions were tested only in Windows XP).

Ii. Export / import using batch file


Since the standard registry tools do not allow exporting individual registry entries, we will again have to deal with the whole section, but now the volume can be narrowed down to the desired HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings . Additional benefits are also in the fact that we do not need to open the player again and do not need to manually enter the name of the bookmark, everything will be done automatically.

1. Batch file

There is no place to be easier (save as a text file with a .bat extension):

 @echo off reg export "hkcu\Software\Gabest\Media Player Classic\Settings" "%~dpn1.reg" 

The argument can be the last video file or a folder from a DVD. In the same directory, a .reg file of the same name is created, which is then conveniently imported with one click before returning to watching a movie.

2. Integration into the system interface

In order not to have to contact the command line every time or drag the video onto the batch file label, we will implement a more convenient connection.

but. Implementation for Explorer

Let's add a call to our batch file to the context menu of files and folders. To do this, it is enough to create the following text file, save it in Unicode with the .reg extension and run for integration (just replace the paths to the program with yours, not forgetting to double the slashes).

 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\* MPC bookmark] [HKEY_CLASSES_ROOT\*\shell\* MPC bookmark\command] @="E:\\DOC\\prg\\bat\\mpc_bm.bat \"%1\"" [HKEY_CLASSES_ROOT\Folder\shell\* MPC bookmark] [HKEY_CLASSES_ROOT\Folder\shell\* MPC bookmark\command] @="E:\\DOC\\prg\\bat\\mpc_bm.bat \"%1\"" 

b. Implementation for Total Commander

Those who are more accustomed to this file manager can create a button on the toolbar (you can duplicate it with the previous recipe with the context menu):



Then it will be possible to create a bookmark for the file that is in focus of the active tab after watching the video.

Ii. Export / Import with Perl Script


Here we can achieve even greater convenience. If someone is not familiar with Perl, it is not scary: just download and install the implementation of the interpreter for Windows , everything else is also not difficult.

With the help of the script, we can save only the necessary keys. If you bookmark right after watching the video, we will only need the very first recordings in the history, they are also the last ones to watch: File Name 0 + File Position 0 or DVD Position 0 . In addition, the script will check the identity of the file argument and the last file in the player's history, so that we do not accidentally leave the wrong tab.

1. Script

Create the following text file and save it with a .pl extension:

 ################################################################################ use strict; use warnings; use Win32::TieRegistry; ################################################################################ $Registry->Delimiter("/"); my $movie = shift(); ################################################################################ if ($movie && -d $movie) { open(OUTPUT, '>:raw:encoding(UTF16-LE)', $movie . ".DVD.reg") or die "Cannot create the .reg file: $!\n"; print OUTPUT "\x{FEFF}Windows Registry Editor Version 5.00\r\n\r\n[HKEY_CURRENT_USER\\Software\\Gabest\\Media Player Classic\\Settings]\r\n", '"DVD Position 0"="', $Registry->{'HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings//DVD Position 0'}, "\"\r\n\r\n"; close(OUTPUT) or die "Cannot close the .reg file: $!\n"; } elsif ($movie && -f $movie) { my $last_file = $Registry->{'HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings//File Name 0'}; if (lc($movie) eq lc($last_file)) { open(OUTPUT, '>:raw:encoding(UTF16-LE)', $last_file =~ s/\.\w+$/.reg/r) or die "Cannot create the .reg file: $!\n"; print OUTPUT "\x{FEFF}Windows Registry Editor Version 5.00\r\n\r\n[HKEY_CURRENT_USER\\Software\\Gabest\\Media Player Classic\\Settings]\r\n", '"File Name 0"="', $last_file =~ s/\\/\\\\/gr, "\"\r\n", '"File Position 0"="', $Registry->{'HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings//File Position 0'}, "\"\r\n\r\n"; close(OUTPUT) or die "Cannot close the .reg file: $!\n"; } else { print "The input file does not match the last played one:\n\n$movie\n\n$last_file\n\n"; system('pause'); } } else { my $last_file = $Registry->{'HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings//File Name 0'}; open(OUTPUT, '>:raw:encoding(UTF16-LE)', $last_file =~ s/^.+\\//r =~ s/\.\w+$/+Last_DVD.reg/r) or die "Cannot create the .reg file: $!\n"; print OUTPUT "\x{FEFF}Windows Registry Editor Version 5.00\r\n\r\n[HKEY_CURRENT_USER\\Software\\Gabest\\Media Player Classic\\Settings]\r\n", '"File Name 0"="', $last_file =~ s/\\/\\\\/gr, "\"\r\n", '"File Position 0"="', $Registry->{'HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings//File Position 0'}, "\"\r\n", '"DVD Position 0"="', $Registry->{'HKEY_CURRENT_USER/Software/Gabest/Media Player Classic/Settings//DVD Position 0'}, "\"\r\n\r\n"; close(OUTPUT) or die "Cannot close the .reg file: $!\n"; } ################################################################################ 

If a folder is transferred to a script, it saves only a bookmark on the last DVD in a .reg file with the folder name (it is not possible for me to check if this is a DVD: if someone knows how to do this, please write in the comments; but if you bookmark right after watching a movie and closing the player, you can not worry about its correctness). If a file is transferred, the script checks the identity of this file and the last file in the history; if the files are the same, the script creates the same .reg file with the two necessary keys, if they do not match, it gives an error message. If no arguments are passed to the script at all, it creates a summary .reg file with information about the last DVD and the last video file in the current active folder.

2. Integration into the system interface

Everything is almost the same with minimal changes (do not forget to prescribe your paths to the programs).

but. Implementation for Explorer

For some reason, specifying a single script is not enough, you also have to set an interpreter (despite the fact that the .pl extension is added to the PATHEXT variable):

 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\* MPC bookmark] [HKEY_CLASSES_ROOT\*\shell\* MPC bookmark\command] @="C:\\Perl\\bin\\perl.exe E:\\DOC\\prg\\perl\\var\\mpc_bm.pl \"%1\"" [HKEY_CLASSES_ROOT\Folder\shell\* MPC bookmark] [HKEY_CLASSES_ROOT\Folder\shell\* MPC bookmark\command] @="C:\\Perl\\bin\\perl.exe E:\\DOC\\prg\\perl\\var\\mpc_bm.pl \"%1\"" 

b. Implementation for Total Commander

Similar button:





The described mechanism allows to achieve this state:



PS Of course, there is still “Favorites” in the player itself, but for some it may seem less convenient: to update a bookmark, that is, change the transition time in the same movie, you need to delete the old bookmark and create a new one; when bookmarks are in folders next to movies, they are easier to find and easier to remove as unnecessary along with movies after viewing; such bookmarks are available from all accounts; they are easier to edit (even in Notepad) if the file name or the path to it is changed.

Source: https://habr.com/ru/post/149436/


All Articles