473,609 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ 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 $directoryListi ng; does not work.
Jan 18 '11 #1
6 4753
RonB
589 Recognized Expert Moderator Contributor
You should have received the following error:
Undefined subroutine &main::SYSTE M 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::Pr ocess).
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
3765
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, the only real candidate that I could find, is no longer available. There are of course general-purpose parsing packages, but I'm looking for something target specifically to Perl-to-Python translation. Since I couldn't find anything, I've...
1
1923
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 redirect my perl scripts stdout to print to this scripts stdin? does that make sense? thanks. sean rowe
0
4720
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 vesrion of BAC software for our backend, see www.buildacommunity.com
2
3501
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
2181
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 BatmoAudiopop.js which opens a pop-up browser window with an audio player when a link is clicked. Basically, it sets the right mime-type depending on the operating system and audio file type, then opens a window with the audio file (passed as a parameter) in...
4
4441
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 Song</title> <link>http://www.feedforall.com/songs.htm</link> <description>FeedForAll cool show tunes and lyrics. </description>
2
2156
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 "value" on an undefined value at C:/Perl/site/lib/Win32/IE/Mec hanize.pm line 900. Please let me know your inputs on the same #!c:\perl\bin\perl.exe
24
3224
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 calls exec or system to give the Perl script the necessary effective permissions. How can I make the C wrapper program secure? or "more" secure? The Perl script, which is "-rwsr-xr-x root root" will look at the real user id and then check a...
8
4218
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 autmating the website ... it will be very helpful for me to start automation...
0
1425
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, ab.v ----------------- contains instantes of ax.v,bx.v cd.v ----------------- contains instances of cx.v,dx.v abcd.v -------- top-level module contains instances of ab.v, cd.v ...
0
8133
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8083
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8224
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8406
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5517
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2535
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 we have to send another system
1
1676
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.