Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
ok...this is the small project that i'm trying. i found a short script on linuxforums.org that would allow one to play launchcast videos (shown below), and found it very convenient ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586

    a couple of scripting questions for a small project that i've decided to try


    ok...this is the small project that i'm trying. i found a short script on linuxforums.org that would allow one to play launchcast videos (shown below), and found it very convenient as i now have links (other scripts...example below) to the videos...so i can play them without ever opening a browser.
    now, the questions...is there a way to modify the script that runs launchcast vids so that the video would always be on top, would be stick'd to all virtual desktops, and would start in the bottom right corner of the screen? my other question is: how would i write a script that would randomly play these files (all located in the same folder)? this one wouldn't have to worry about playing the same one twice...as i don't mind if it does.

    now, the scripts that i've already created:
    to play launchcast vids (i wasn't the original author...i found it online):
    named - lcvid
    Code:
    #!/bin/bash
    
    if [ $# -eq 0 ]; then
    echo "Usage&#58; launch.sh <videoid> &#40;<bandwidth>&#41; &#40;<protocol>&#41; <mplayer-options>"
    echo " videoid = Lauch Video ID"
    echo " bandwidth = 56,128,300 &#40;default 300&#41;"
    echo " protocol = mms,http &#40;default mms&#41;"
    echo " mplayer options can be passed via command line"
    echo "Example&#58;"
    echo " MMS&#58;"
    echo " launch.sh 1112809 300 mms"
    echo " HTTP&#58;"
    echo " launch.sh 1112809 300 http"
    echo " HTTP with mplayer options&#58;"
    echo " launch.sh 1112809 300 http -verbose 0 -cache 500"
    exit 0
    fi
    
    videoid=$1
    shift
    
    if &#91; $1 -eq $1 &#93; && &#91; $1 != 0 &#93;; then
    bandwidth=$1
    shift
    else
    # 56 or 128 or 300
    bandwidth=300
    fi
    
    file1=$&#40;wget "http&#58;//launchtoday.launch.yahoo.com/player/medialog.asp?vid=$videoid&cid=1&pid=4&csid=396500550&p1=&p2=&p3=2&bw=$bandwidth&mf=1&origin=35&pguid=AA388C059C7849D99CCFBC72B6F51E37&uid=42&sk=bad551cd352143eb2da02&z=ms.asx" -q -O -&#41;
    
    if &#91; $1 == "http" &#93;; then
    file2=$&#40;wget "$file1" -q -O - | sed 's/mms&#58;/http&#58;/g'&#41;
    shift
    else
    file2=$&#40;wget "$file1" -q -O -&#41;
    fi
    
    mplayer -cache 500 $file2 $@
    example of one of my short scripts to play the vids:
    Code:
    xterm -e "lcvid #######"
    the number is a number assigned by launchcast to each video


    thanks in advance for any and all help with this!

  2. #2
    Just Joined!
    Join Date
    Oct 2005
    Posts
    31
    Well, I can help you with part of your problem. Change the following:
    Code:
    mplayer -cache 500 $file2 $@
    To this:
    Code:
    mplayer -ontop -cache 500 $file2 $@
    That will make mplayer stay on top of all other windows. As for launching files randomly... I will leave that for someone else. I know that you will need to loop indefinitely choosing random vids for wget, choosing valid vids will be a problem.

  3. #3
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586
    Quote Originally Posted by Loridan
    Well, I can help you with part of your problem. Change the following:
    Code:
    mplayer -cache 500 $file2 $@
    To this:
    Code:
    mplayer -ontop -cache 500 $file2 $@
    That will make mplayer stay on top of all other windows. As for launching files randomly... I will leave that for someone else. I know that you will need to loop indefinitely choosing random vids for wget, choosing valid vids will be a problem.
    thanks ...now it's always on top

  4. #4
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586
    *bump*

    does anyone know how to randomly select a code to run from within a folder? (regardless of name). i thought, maybe create an array that would store all of these files in it...but as numbers within the array. than randomly select a number in the array and that would correspond with the file. would this be possible? i have/had minimal java experience in the past and we (class) never did much...it was all applets, but i'm assuming this may be possible.

    also, how would i customize the script above (lcvid) so that the vid that is played would be "stick"'d to all of the virtual screens and would open in the bottom right corner of the screen? for the opening in a certain part of the screen...is there a way to make a window open at a certain coordinate? if so, that should work...i can always play around with it to get it right

  5. #5
    Just Joined!
    Join Date
    Oct 2005
    Posts
    31

    Some consider this taboo

    Some consider this taboo, however, I like to program with ruby. Honestly, if it were me, I would write down all of the videos that you are interested in, and include each one on a seperate line in a file called videos.dat. Then I would create a ruby script that will automatically grab one of these files at random.

    Code:
    #!/usr/bin/ruby
    videos = Array.new
    File.open&#40;"/path/to/videos.dat"&#41;.each&#123;|line| videos.push&#40;line.chop&#41;&#125;
    while 1
         randomvid = videos&#91;rand&#40;videos.length&#41;&#93;
         system&#40;"./path/to/lcvid #&#123;randomvid&#125;"&#41;
    end
    This simple script will load all of the file names that you typed on seperate lines in videos.dat into an array and loop forever randomly picking one to play with your shell script lcvid. You will have to kill this app with ctrl-c.

    I hope that is what you are looking for.

  6. #6
    Linux Engineer
    Join Date
    Nov 2004
    Location
    home
    Posts
    796
    You can use wmctrl to make windows sticky or on top.

  7. #7
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586

    Re: Some consider this taboo

    Quote Originally Posted by Loridan
    Some consider this taboo, however, I like to program with ruby. Honestly, if it were me, I would write down all of the videos that you are interested in, and include each one on a seperate line in a file called videos.dat. Then I would create a ruby script that will automatically grab one of these files at random.

    Code:
    #!/usr/bin/ruby
    videos = Array.new
    File.open&#40;"/path/to/videos.dat"&#41;.each&#123;|line| videos.push&#40;line.chop&#41;&#125;
    while 1
         randomvid = videos&#91;rand&#40;videos.length&#41;&#93;
         system&#40;"./path/to/lcvid #&#123;randomvid&#125;"&#41;
    end
    This simple script will load all of the file names that you typed on seperate lines in videos.dat into an array and loop forever randomly picking one to play with your shell script lcvid. You will have to kill this app with ctrl-c.

    I hope that is what you are looking for.
    that looks very good, but i've already written 170 short video-playing scripts. is there a way to load those into the videos.dat file automatically? that would make things a lot easier, and i wouldn't have to add a new video into the videos.dat file everytime i create another short script.

    i customized your script some and have it so it'll load videos by name:
    Code:
    #!/usr/bin/ruby
    videos = Array.new
    File.open&#40;"/home/josh/launchcast-vids/videos.dat"&#41;.each&#123;|line| videos.push&#40;line.chop&#41;&#125;
    while 1
         randomvid = videos&#91;rand&#40;videos.length&#41;&#93;
         system&#40;"/home/josh/launchcast-vids/#&#123;randomvid&#125;"&#41;
    end
    ...all i really need now is for it to automatically add the list of names (scripts) into the videos.dat file...if that's possible. if it's not, than i guess i can add them.
    i was thinking, maybe these steps would work?
    delete the file, create another one, use "echo (file) >> videos.dat" to add each one but do it repeatedly until it runs out of names to add


    something like this:
    Code:
    echo &#40;output of "ls -Q /home/josh/launchcast-vids/"&#41; >> /home/josh/launchcast-vids/videos.dat
    can someone give me a way to do this?


    nevermind...i figured it out
    Code:
    ls -Q /home/josh/launchcast-vids/ > /home/josh/launchcast-vids/videos.dat

  8. #8
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586
    Quote Originally Posted by valan
    You can use wmctrl to make windows sticky or on top.
    thanks...that should take care of the sticky and where to move the window. how would i integrate it now? any ideas?

    it seems like, if i put this after opening mplayer (in lcvid), it will never happen (it seems like mplayer is where the script stops without going any further). this is where i run into problems. it doesn't even seem to bother finding out what happens after starting mplayer...is there a way to tell it the windows dimensions before loading the window maybe?

  9. #9
    Just Joined!
    Join Date
    Oct 2005
    Posts
    31

    Holy honkin gooslings batman.

    I didnt realize that the files you were playing actually existed in your directory structure, I thought they were fetched. If that is the case you dont even need the videos.dat file.


    Code:
    #!/usr/bin/ruby
    videos = Array.new
    Dir.entries&#40;"/home/josh/launchcast-vids/"&#41;.each&#123;|file|videos.push&#40;file&#41;&#125;
    while 1
         randomvid = videos&#91;rand&#40;videos.length&#41;&#93;
         system&#40;"/home/josh/launchcast-vids/#&#123;randomvid&#125;"&#41;
    end
    Wooooooh! that was fun, ok Im going back to my cage now...

  10. #10
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586

    Re: Holy honkin gooslings batman.

    Quote Originally Posted by Loridan
    I didnt realize that the files you were playing actually existed in your directory structure, I thought they were fetched. If that is the case you dont even need the videos.dat file.


    Code:
    #!/usr/bin/ruby
    videos = Array.new
    Dir.entries&#40;"/home/josh/launchcast-vids/"&#41;.each&#123;|file|videos.push&#40;file&#41;&#125;
    while 1
         randomvid = videos&#91;rand&#40;videos.length&#41;&#93;
         system&#40;"/home/josh/launchcast-vids/#&#123;randomvid&#125;"&#41;
    end
    Wooooooh! that was fun, ok Im going back to my cage now...
    thanks
    that seems to make things a little simpler now


    now, only if i could figure out how to get wmctrl to run somewhere in this with the mplayer window....

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •