LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help with simple scripting (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-with-simple-scripting-729485/)

greengrocer 05-30-2009 05:22 AM

Need help with simple scripting
 
Hello all,

I am trying to launch Xine and then queue some files into Xine without using a conventional play list file.

So far, I have discovered that from a terminal I can:

1) I can launch Xine and specify a session ID using:

Code:

xine -S --session=0 &
2) Inject an mrl into the Xine session by using:

Code:

xine --enqueue -S session=0 /media/Video/v/a_file.mpg
3) Inject a second mrl into the Xine session by using:

Code:

xine --enqueue -S session=0 /media/Video/v/b_file.mpg
And get the desired result, file a plays to the end and then file b plays, all in the same Xine instance.

How would I get this to work in a script that I could execute once, without having to manually issue the three commands in the terminal?


Hope this is making some sense and someone is happy to help.

Regards,
Greenie

Samotnik 05-30-2009 06:34 AM

Why don't you simply start xine as xine <first file> <second file>??

greengrocer 05-30-2009 09:11 PM

Quote:

Originally Posted by Samotnik (Post 3557388)
Why don't you simply start xine as xine <first file> <second file>??

Because there are a thousand files, and each one of them needs a different volume setting. Some files are MPG video and some are AVI, so I don't want to adjust the volume of each file because that is way too time consuming.

What I ultimately want to do is write a script that randomly chooses a filename from a list and chooses a volume setting from same list (text file list) and injects the filename and volume setting into a running instance of xine.

I can do this by command line, so surely a script can do it. I just not sure how. I've tried to write one but cannot get it to work (my script keeps launching multiple instances of xine, I have to close each instance one by one for the next instance to start).

syg00 05-30-2009 09:25 PM

Well, let's see your attempt.

greengrocer 05-31-2009 12:09 AM

Quote:

Originally Posted by syg00 (Post 3557854)
Well, let's see your attempt.

Code:

xine -S --session=0 &
xine --enqueue -S session=0 /media/Video/kelly_video.mpg
xine --enqueue -S session=0 /media/Video/changes_video.mpg

...It is identical to what I type at the command line. When I type at the command line, xine behaves the way I would expect and need. When I run the above as a script it does something completely different.

I suspect that my approach on the first line is way incorrect, but I don't know what would be correct way of doing this.

syg00 05-31-2009 02:09 AM

So you're issuing this as "sh whatever" ?.
Try adding "#!/bin/sh" as the first line, make it executable and run it.

greengrocer 06-01-2009 05:22 AM

Quote:

Originally Posted by syg00 (Post 3557967)
So you're issuing this as "sh whatever" ?.
Try adding "#!/bin/sh" as the first line, make it executable and run it.

Yep added #!/bin/sh as the first line and then ran it. Separate instances of xine occur, i.e. each instance finishes playing the mpg file and then you have to close that instance before the next new instance of xine appears.

Not really the xine behaviour I wanted, it does not behave the same way as it does if I issue those same commands manually in a terminal window.

greengrocer 06-01-2009 06:02 AM

Since the exact same commands work if a slow old human enters them, I figured that the script is running too quickly and each command is not realising that Xine is already running.

And this seems to work:

Code:

#!/bin/sh
xine -S --session=0 &
sleep 2
xine --enqueue -S session=0,mrl=/media/Video/kelly_video.mpg#volume:100
sleep 2
xine --enqueue -S session=0,mrl=/media/Video/changes_video.mpg#volume:70



All times are GMT -5. The time now is 06:45 AM.