473,486 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Automate VLC player in perl?

Srijith B
20 New Member
I want to write a code in perl which automatically opens vlc player and start playing.

I am stuck when I open the vlc player.
I use

Expand|Select|Wrap|Line Numbers
  1. SYSTEM("vlc");
  2.  
But when I execute the lines below this code doesn't not execute.
Is there any other way to open vlc player?

ok, I changed my code
Here is it

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2.  
  3. #exec (vlc);
  4. #print "vlc launched";
  5. $directoryListing = `vlc`;
  6. print $directoryListing;            //opens vlc
  7.  
  8. print "vlc playinng";
  9.  
  10. my @keys = ("%{m}", "{ENTER}");
  11. for my $key (@keys){
  12.  
  13. SendKeys ($key);
  14. }
  15.  
Problem here is once I execute, the statements after print $directoryListing; does not work.
Jan 18 '11 #1
6 4737
RonB
589 Recognized Expert Moderator Contributor
You should have received the following error:
Undefined subroutine &main::SYSTEM called at
Perl is case sensitive.

It's system not SYSTEM
Jan 18 '11 #2
chorny
80 Recognized Expert New Member
Do a fork and run vlc in fork. `` waits for program to finish.
Jan 26 '11 #3
Srijith B
20 New Member
I dont want to wait after I run vlc. I want the below statements to execute after the vlc is opened.
what I get is
The VLC will open and a message "[0x9bfa140] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface." appears in the terminal and the program is waiting for vlc to quit. once the vlc quits(CTRL +C or close vlc using mouse) the rest of the statements execute. Btw I tried forking and had no luck.. same result.
here the forking code
Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2. $pid = fork();
  3. if( $pid == 0){
  4. system("vlc");
  5. exit 0;
  6. }
  7. print "vlc playinng";
  8.  
  9.  my @keys = ("%{m}", "{ENTER}");
  10.  for my $key (@keys){
  11. SendKeys ($key);
  12. }
  13.  
  14.  
  15.  
Feb 28 '11 #4
miller
1,089 Recognized Expert Top Contributor
The following example with fork does work for me, however, the script won't exit until vlc is closed.

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2.  
  3. use strict;
  4.  
  5. my $vlc = q{C:\Program Files\VideoLAN\VLC\vlc.exe};
  6.  
  7. unless (fork) {
  8.     system($vlc);
  9.     exit;
  10. }
  11.  
  12. print "Hello world\n";
  13.  
Since you're running on a windows machine though, you have the option of using Win32::Process

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2.  
  3. use Win32::Process;
  4.  
  5. use strict;
  6.  
  7. my $vlc = q{C:\Program Files\VideoLAN\VLC\vlc.exe};
  8.  
  9. Win32::Process::Create(
  10.     my $processobj,
  11.     $vlc,
  12.     "vlc",
  13.     0,
  14.     NORMAL_PRIORITY_CLASS,
  15.     "."
  16. ) or die "Can't Create - $!";
  17.  
  18. print "Hello world\n";
  19.  
The above will start vlc, and continue to Hello World and exit, leaving vlc running.

- Miller
Mar 2 '11 #5
Srijith B
20 New Member
sorry for not mentioning the OS.
I am using Linux ubuntu.
I have a well running vlc automation script in windows.
And yes, I used the same package as the above(Win32::Process).
But you know that we cant use these in linux.

I am unaware of packages in linux that is to be used.
Mar 3 '11 #6
miller
1,089 Recognized Expert Top Contributor
Well, if all else fails, just use & to start the process as an independent daemon.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl-w
  2. # waitforme.pl
  3.  
  4. use strict;
  5.  
  6. my $log = 'waitforme.log';
  7.  
  8. open my $fh, '>>', $log or die "$log, $!";
  9. for (1..5) {
  10.     print $fh scalar(localtime), " - $_\n";
  11.     sleep 2;
  12. }
  13.  
and the main script

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl-w
  2. # dontwait.pl
  3.  
  4. use strict;
  5.  
  6. my $prog = q{perl waitforme.pl};
  7.  
  8. system(qq{$prog &});
  9.  
  10. print "Hello world\n";
  11.  
- Miller
Mar 3 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3755
by: Stephen Ferg | last post by:
I need to translate some Perl scripts into Python. When I went looking for a tool that would help automate the translation, I was rather surprised that I couldn't find anything. BridgeKeeper,...
1
1918
by: Someone | last post by:
there's a korn shell script that i would like to wrap a perl script around to automate it, as a task i need to do always chooses the same options from this script (it's menu driven). can i somehow...
0
4712
by: Greg | last post by:
We're looking for CGI/PERL programmer who can help us integrate CamFrogWeb's video conferencing software with our site's user management system (login system) Our site uses customized...
2
3493
by: Santosh | last post by:
Dear all i am created one animated image in Macromedia flash player i want to call it from asp.net page. how i can call it. help greatly apreciated. Santosh Shinde.
2
2167
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called...
4
4435
by: subeen | last post by:
Hi, I am trying to parse a rss similar to the one found here (in example) http://www.feedforall.com/mediarss.htm <!-- Snipped for Brevity --> <item> <title>FeedForAll's Show Tunes and...
2
2149
by: mithunmo | last post by:
I am trying to automate the process of filling up the webforms and do a submit . I have the below program written but If I run the program . I get the following error message Can't call method...
24
3198
by: Peter Michaux | last post by:
I have a Perl script that I want to run as a set-user-ID program. Many OSes don't allow scripts run as set-user-ID. To make this script portable, it seems I need to write a C wrapper program that...
8
4206
by: gajendra98 | last post by:
Hi All I Have installed Active perl in my system and I am new to perl and automation...Could some one tell me how to install the perl modules and how to use those modules with the perl for...
0
1419
by: raghavendrap | last post by:
Hello friends, I need help to automate verilog modules. Suppose i have verilog modules ax.v, bx.v, cx.v, dx.v ---------- individual modules, ...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.