this works great if you have a ton of media in a folder and want to randomly watch any given inside in that directory, and you do not have to worry about spaces in path/filenames. and this is also for windows but i think it could be used on any other platform as well with small changesuse strict; use warnings; use diagnostics; use File::Random qw(random_file); my $dir = $ARGV[0]; if ( not defined $dir ) { print "\nUsage: random.pl [folder]; exit(0); }else{ random($dir); } sub random{ my ($dir) = @_; while (1){ my $mpc = "C:/Program Files (x86)/K-Lite Codec Pack/Media +Player Classic/mpc-hc.exe"; my $rndm_file = random_file( -dir => $dir, #-check => qr/./, -recursive => 1 ); if ($rndm_file =~ /\.(ini|nfo|db)$/i){ print "$rndm_file\n"; random($dir); } print $rndm_file; #get duration my $t = ("MediaInfo.exe --Output=Video;%Duration% \"F:/TV/ +$rndm_file\""); system(1, $mpc, "F:/TV/$rndm_file"); my $time = qx($t); my $sleep_time = $time/1000; #in seconds because m +ediainfo.exe outputs milliseconds i think. print "\nDuration in seconds: $sleep_time\n"; sleep($sleep_time); random($dir); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Random video player
by toolic (Bishop) on Oct 29, 2014 at 18:21 UTC | |
by james28909 (Deacon) on Oct 29, 2014 at 18:46 UTC | |
by karlgoethebier (Abbot) on Oct 30, 2014 at 12:57 UTC | |
by james28909 (Deacon) on Oct 30, 2014 at 18:25 UTC | |
|
Re: Random video player
by GotToBTru (Prior) on Oct 29, 2014 at 18:05 UTC | |
by james28909 (Deacon) on Oct 29, 2014 at 18:08 UTC | |
by james28909 (Deacon) on Oct 29, 2014 at 18:14 UTC | |
by GotToBTru (Prior) on Oct 29, 2014 at 18:54 UTC |