Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 14 Octubre 2011, 15:26 pm



Título: [Perl] DH Player
Publicado por: BigBear en 14 Octubre 2011, 15:26 pm
Bueno , este es un simple reproductor de musica que hice en perl
En esta version podran tener buscar musica y reproducirla todo en una ventana grosa

Código
  1. #!usr/bin/perl
  2. #DH Player 0.1
  3. #(C) Doddy Hackman 2011
  4.  
  5. use Tk;
  6. use Win32::MediaPlayer;
  7.  
  8. if ($^O eq 'MSWin32') {
  9. use Win32::Console;
  10. Win32::Console::Free();
  11. }
  12.  
  13.  
  14. $test = new Win32::MediaPlayer;
  15.  
  16. $new = MainWindow->new(-background=>"black");
  17. $new->geometry("350x420+20+20");
  18. $new->resizable(0,0);
  19. $new->title("DH Player 0.1 (C) Doddy Hackman 2011");
  20. $new->Label(-background=>"black",-foreground=>"green",-font=>"Impact",-text=>"Directory : ")->place(-x=>"20",-y=>"20");
  21. my $dir = $new->Entry(-background=>"black",-foreground=>"green",-text=>"C:\\Users\\Daniel\\Desktop\\WarFactory\\Perl\\musica")->place(-x=>"100",-y=>"25");
  22. $new->Button(-background=>"black",-foreground=>"green",-activebackground=>"green",-text=>"Search",-width=>"10",-command=>\&buscar)->place(-x=>"240",-y=>"25");
  23. $new->Label(-background=>"black",-foreground=>"green",-text=>"Files Found",-font=>"Impact")->place(-y=>"95",-x=>"120");
  24. my $lists = $new->Listbox(-background=>"black",-foreground=>"green")->place(-y=>"130",-x=>"100");
  25. $new->Button(-background=>"black",-foreground=>"green",-text=>"Play",-width=>"55",-activebackground=>"green",-command=>\&play)->place(-y=>"310");
  26. $new->Button(-background=>"black",-foreground=>"green",-text=>"Pause",-width=>"55",-activebackground=>"green",-command=>\&pause)->place(-y=>"333");
  27. $new->Button(-background=>"black",-foreground=>"green",-text=>"Resume",-width=>"55",-activebackground=>"green",-command=>\&resume)->place(-y=>"356");
  28. $new->Button(-background=>"black",-foreground=>"green",-text=>"Stop",-width=>"55",-activebackground=>"green",-command=>\&stop)->place(-y=>"379");
  29.  
  30.  
  31. MainLoop;
  32.  
  33.  
  34. sub play {
  35.  
  36. my $dir = $dir->get;
  37.  
  38. $d = $lists->curselection();
  39.  
  40. for my $id (@$d) {
  41. my $cancion = $lists->get($id);
  42. $test->load($dir."\\".$cancion);
  43. $test->play;
  44. }
  45.  
  46. }
  47.  
  48. sub stop {
  49. $test->close;
  50. }
  51.  
  52. sub pause {
  53.  
  54. my $dir = $dir->get;
  55.  
  56. $d = $lists->curselection();
  57.  
  58. for my $id (@$d) {
  59. my $cancion = $lists->get($id);
  60. $test->pause;
  61. }
  62.  
  63. }
  64.  
  65. sub resume {
  66.  
  67. my $dir = $dir->get;
  68.  
  69. $d = $lists->curselection();
  70.  
  71. for my $id (@$d) {
  72. my $cancion = $lists->get($id);
  73. $test->resume;
  74. }
  75.  
  76. }
  77.  
  78. sub buscar {
  79.  
  80. $lists->delete(0.0,"end");
  81.  
  82. #$dir = "C:\\Users\\Daniel\\Desktop\\WarFactory\\Perl\\musica";
  83.  
  84. my $dir = $dir->get;
  85.  
  86. opendir DIR,$dir;
  87.  
  88. my @archivos = readdir DIR;
  89.  
  90. close DIR;
  91.  
  92. chomp @archivos;
  93.  
  94. foreach my $file(@archivos) {
  95. if (-f $dir."\\".$file) {
  96. $lists->insert("end",$file);
  97. }
  98. }
  99.  
  100. }
  101.  
  102.  
  103. # ¿ The End ?
  104.  
  105.  
  106.