Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Streaming music script

Theora Aquitaine
Registered User
Join date: 12 Feb 2006
Posts: 266
06-20-2006 11:06
New version (0.8) released with very minor addition (you can now press "s" to stop all the currently playing streams). As usual, uploaded to:

http://stux.wikiinfo.org/moin.py/Tools
Theora Aquitaine
Registered User
Join date: 12 Feb 2006
Posts: 266
06-30-2006 16:43
I have just released version 0.9. This just removes the xhost + bit. I decided it was too much of a security hole. If you use xhost, and the new slstream will not work, type xhost + before running the script (and xhost - immediately after!), but please ensure you are also using xauth, or have X11 forwarding switched off!
Theora Aquitaine
Registered User
Join date: 12 Feb 2006
Posts: 266
07-22-2006 16:33
Just noticed in the latest version of SL, video streams have stopped working with slstream.

The problem is the tag has changed from 8 to 12. I have uploaded a new version of the script which should now work with video as well as audio streams.

http://stux.wikiinfo.org/moin.py/Tools
Suntan Nadir
Registered User
Join date: 16 Jun 2006
Posts: 22
trouble with web pages
08-10-2006 07:31
Is anyone else having problems calling up web pages with the script?

I am getting music streams and video no problem, but can't seem to get web pages anymore. Admittedly I've only tried getting jukebox requests in The Elbow Room! Earlier versions of the script up to 0.9 worked fine but not since using the current and previous version of SL (v 1_11_3_1) and v 0.10 of the script.

Not a disaster, but I had got used to getting web access.......

Clues gratefully received.... :)

S
Theora Aquitaine
Registered User
Join date: 12 Feb 2006
Posts: 266
08-10-2006 11:11
From: Suntan Nadir
Is anyone else having problems calling up web pages with the script?

I am getting music streams and video no problem, but can't seem to get web pages anymore. Admittedly I've only tried getting jukebox requests in The Elbow Room! Earlier versions of the script up to 0.9 worked fine but not since using the current and previous version of SL (v 1_11_3_1) and v 0.10 of the script.

Not a disaster, but I had got used to getting web access.......

Clues gratefully received.... :)

S


I never really was convinced the web thing was working but I'm glad it worked for you for a while....

If you could let me know where I can test it out (SL location etc.) I will try to fix it.

I think it is likely that the tag for web urls has changed with one of the recent releases, as movie tags changed.
Suntan Nadir
Registered User
Join date: 16 Jun 2006
Posts: 22
08-10-2006 12:22
In the past it has always worked in the Elbow Room (Mare 106,51,56). Typing "/jukebox" always used to bring up the browser. But alas no more...... I have to dance to other people tunes (just like RL hmmmmm).

I wondered if the tag had changed. But was beyond my competence to check :(

S

PS Thanks Theora (and Christine)..... this script has made soooo much difference to SL!! Excellent stuff :)
Theora Aquitaine
Registered User
Join date: 12 Feb 2006
Posts: 266
08-10-2006 15:04
From: Suntan Nadir
In the past it has always worked in the Elbow Room (Mare 106,51,56). Typing "/jukebox" always used to bring up the browser. But alas no more...... I have to dance to other people tunes (just like RL hmmmmm).

I wondered if the tag had changed. But was beyond my competence to check :(

S

PS Thanks Theora (and Christine)..... this script has made soooo much difference to SL!! Excellent stuff :)


Suntan: as you know I have now fixed the script!

For everyone else, the tag has changed to 234 for web pages.. I am doing some research into what other tags mean too.. The new version will be uploaded to the usual place when I get the chance.. bed now!

Edit: Wiki seems to be read only at the moment, so I'm afraid people will have to download 0.10 and make the change to the web tag themselves for the time being.
Suntan Nadir
Registered User
Join date: 16 Jun 2006
Posts: 22
08-24-2006 02:27
Hmmmm, well it looks like the tag for web pages has changed again with the latest version (1.12.0.13) as my requests are failing again in the Elbow Room! Is there an easy way to check?

S
Theora Aquitaine
Registered User
Join date: 12 Feb 2006
Posts: 266
08-25-2006 17:05
It's now 237..

Just use print tag to get a list of all the tags the script picks up..
Suntan Nadir
Registered User
Join date: 16 Jun 2006
Posts: 22
08-26-2006 07:25
Thanks Theora..... :)

S
Theora Aquitaine
Registered User
Join date: 12 Feb 2006
Posts: 266
08-26-2006 15:06
Oh and just to make matters more confusing, the video tag is now 4!

CODE

#!/usr/bin/python
#SLStream by Theora Aquitaine and Christine Montgomery
#
#This work is licensed under the Creative Commons Attribution-ShareAlike 2.5
#License. To view a copy of this license, visit
#http://creativecommons.org/licenses/by-sa/2.5/ or send a letter to Creative
#Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
#

import pcapy
import os
import thread
import curses
import sys
import signal

####Configuration####

###edit to add your username and mediaplayer etc:###

user='username'
musicplayer='xmms'
videoplayer='mplayer'
browser='firefox'
radio=True
tv=True
web=True
#close and reopen musicplayer for each stream
musrestart=False
#close and restart videoplayer for each stream
vidrestart=True
#close videoplayer at shutdown
vidshutdown=True
#close musicplayer at shutdown
musshutdown=True

####End configuration section###

def recv_pkts(hdr, data):
global lastradio
global lastvideo
global lastweb
b=data.find('http')
while b>-1:
len=ord(data[b-1])
tag=ord(data[b-2])
d=data[b:b+len-1]
if tag==1 and radio==1 and d!=lastradio:
lastradio=d
curseserase() stdscr.addstr('launching '+d+'\n')
stdscr.refresh()
if musrestart:
os.system('pkill -9 '+musicplayer)
cmd='su '+user+' -c "'+musicplayer+' '+d+'&>/dev/null &"'
os.system(cmd)
elif tag==4 and tv==1 and d!=lastvideo:
lastvideo=d
curseserase()
stdscr.addstr('launching '+d+'\n')
stdscr.refresh()
if vidrestart:
os.system('pkill -9 '+videoplayer)
cmd='su '+user+' -c "'+videoplayer+' '+d+'&>/dev/null &"'
os.system(cmd)
elif tag==237 and web==1:
curseserase()
stdscr.addstr ('opening site '+d+'\n')
stdscr.refresh()
cmd='su '+user+' -c "'+browser+' '+d+'&"'
os.system(cmd)
b=data.find('http', b+1)

def quitnow(*sig):
cursesoff()
if musshutdown:
os.system('pkill -9 '+musicplayer)
if vidshutdown:
os.system('pkill -9 '+videoplayer)
sys.exit()

def cursesoff():
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()

def curseson():
stdscr=curses.initscr()
curses.cbreak()
stdscr.keypad(0)
curses.noecho()
return stdscr

def curseserase():
stdscr.erase()
stdscr.addstr('SLStream Version 0.12 By Theora Aquitaine and'+\
' Christine Montgomery\n')
stdscr.addstr('Released under a Creative Commons License \n\n')
stdscr.addstr('Radio on:'+str(radio)+'\n')

lastradio=''
lastvideo=''
lastweb=''
dev='any'
p = pcapy.open_live(dev, 1500, 0, 100)
p.setfilter('udp')
thread.start_new_thread(p.loop, (-1, recv_pkts))
stdscr=curseson()
curseserase()
signal.signal(signal.SIGINT, quitnow)
while 1:
curseserase()
key=stdscr.getch()
try: keypress=chr(key)
except: continue
if keypress=='r':
radio=not(radio)
os.system('pkill -9 '+musicplayer)
if keypress=='t':
tv=not(tv)
os.system('pkill -9 '+videoplayer)
if keypress=='w':
web=not(web)
if keypress=='q':
quitnow()
if keypress=='s':
os.system('pkill -9 '+musicplayer)
os.system('pkill -9 '+videoplayer)
1 2