[Perl Tk] DH Player

Iniciado por BigBear, Julio 03, 2011, 09:59:37 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Julio 03, 2011, 09:59:37 PM Ultima modificación: Julio 17, 2011, 03:44:29 AM por Sthefano02
Un feo pero funcional reproductor mp3

Imagen





Código: perl

#!usr/bin/perl
#DH Player 0.1
#(C) Doddy Hackman 2011
#ppm install http://www.bribes.org/perl/ppm/Win32-MediaPlayer.ppd

use Tk;
use Tk::DirTree;
use Win32::MediaPlayer;

if ($^O eq 'MSWin32') {
use Win32::Console;
Win32::Console::Free();
}

$test = new Win32::MediaPlayer;

$new = MainWindow->new(-background=>"black");
$new->geometry("350x420+20+20");
$new->resizable(0,0);
$new->title("DH Player 0.1 (C) Doddy Hackman 2011");
$new->Label(-background=>"black",-foreground=>"yellow",-font=>"Impact",-text=>"Directory : ")->place(-x=>"20",-y=>"20");
my $dir = $new->Entry(-background=>"black",-foreground=>"yellow",-text=>"C:\\Users\\Daniel\\Desktop\\WarFactory\\Perl\\musica")->place(-x=>"100",-y=>"25");
$new->Button(-background=>"black",-foreground=>"yellow",-activebackground=>"yellow",-text=>"Search",-width=>"10",-command=>\&buscar)->place(-x=>"240",-y=>"25");
$new->Label(-background=>"black",-foreground=>"yellow",-text=>"Files Found",-font=>"Impact")->place(-y=>"95",-x=>"120");
my $lists = $new->Listbox(-background=>"black",-foreground=>"yellow")->place(-y=>"130",-x=>"100");
$new->Button(-background=>"black",-foreground=>"yellow",-text=>"Play",-width=>"55",-activebackground=>"yellow",-command=>\&play)->place(-y=>"310");
$new->Button(-background=>"black",-foreground=>"yellow",-text=>"Pause",-width=>"55",-activebackground=>"yellow",-command=>\&pause)->place(-y=>"333");
$new->Button(-background=>"black",-foreground=>"yellow",-text=>"Resume",-width=>"55",-activebackground=>"yellow",-command=>\&resume)->place(-y=>"356");
$new->Button(-background=>"black",-foreground=>"yellow",-text=>"Stop",-width=>"55",-activebackground=>"yellow",-command=>\&stop)->place(-y=>"379");
$new->Button(-background=>"black",-foreground=>"yellow",-text=>"Browse",-width=>10,-command=>\&bro,-activebackground=>"yellow")->place(-x=>240,-y=>48);

MainLoop;

sub bro {
my $ven = MainWindow->new();
$ven->title("Choose Directory");
$ven->geometry("300x280+20+20");
$ven->resizable(0,0);
$ven->Scrolled("DirTree",-width=>100,-height=>20,-command=>\&choose)->pack();

sub choose {
$dir->configure(-text=>$_[0]);
$ven->destroy;
}
}

sub play {

my $dir = $dir->get;

$d = $lists->curselection();

for my $id (@$d) {
my $cancion = $lists->get($id);
$test->load($dir."\\".$cancion);
$test->play;
}

}

sub stop {
$test->close;
}

sub pause {

my $dir = $dir->get;

$d = $lists->curselection();

for my $id (@$d) {
my $cancion = $lists->get($id);
$test->pause;
}

}

sub resume {

my $dir = $dir->get;

$d = $lists->curselection();

for my $id (@$d) {
my $cancion = $lists->get($id);
$test->resume;
}

}

sub buscar {

$lists->delete(0.0,"end");

my $dir = $dir->get;

opendir DIR,$dir;

my @archivos = readdir DIR;

close DIR;

chomp @archivos;

foreach my $file(@archivos) {
if (-f $dir."\\".$file) {
if ($file=~/wma/ or $file=~/mp3/) {
$lists->insert("end",$file);
}
}
}

}


# ¿ The End ?