Hi!!! If anyone is interested, I find a way to make sopcast streaming work directly in XBMC using Ubuntu (it's not perfect and very tricky cause my bash-scripting skills are not as good as requested
, but it does its job pretty well!!). Last thing to say before starting this "tutorial": as you can see this is a modification of the former posted scripts, I hope no one will be offended if I changed it for my purposes
!
First of all you have to add sopcast-player repository and install it (this will also install a gui, install only sp-auth package if you don't need it!), then you
have to enable XBMC web server function and download curl (for using web-server functionalities):
Code:
sudo add-apt-repository ppa:jason-scheunemann/ppa
sudo apt-get install sopcast-player curl
Then you have to create (or simply modify if it already exists) the playercorefactory.xml file in ~/.xbmc/userdata/ folder in the way shown below,
changing YOURHOMEFOLDER with your home folder name:
Code:
<playercorefactory>
<players>
<player name="Sopcast" type="ExternalPlayer" audio="false" video="false">
<filename>/home/YOURHOMEFOLDER/sopcast</filename>
<args>"{1}" &</args>
<hidexbmc>false</hidexbmc>
<hideconsole>true</hideconsole>
</player>
</players>
<rules action="prepend">
<rule protocols="sop" player="Sopcast"/>
</rules>
</playercorefactory>
Then you have to create a file named "sopcast" in your home folder (using gedit for example) with the following code inside,
changing InterfaceName with the one you're using for connecting with the internet: this is very important because it needs to catch your pc IP to start the streaming (i've done this for people who use DHCP instead of static IP address). I'm using wifi, so it's wlan0. If you're using LAN it probably (but not surely!!) will be eth0:
Code:
#!/bin/sh
# Script for utilize Sopcast with XBMC
# Close any sp-sc process, if there are someone already started.
if pgrep -f "sp-sc"
then
echo sopcast: closing sp-sc process... >&2
Msg=$(echo Sopcast already started,Killing all processes... | sed 's/ /%20/g')
curl -m 3 127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn%28Notification%28$Msg%29%29
pkill -9 sp-sc
fi
echo sopcast: opening $1 stream on port 8902 >&2
sp-sc "$1" 3908 8902 >/dev/null &
sleep 1 # Wait for SP_SC to being started (not the best solution, though...)
SP_SC=`pgrep -f "sp-sc $1 3908 8902"`
# Checking if the streaming exist
if test -z $SP_SC
then
echo sopcast: streaming $1 failed >&2
Msg=$(echo Error,Streaming does not exist! | sed 's/ /%20/g')
curl -m 3 127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn%28Notification%28$Msg%29%29
exit 1
fi
# Getting streaming number from the input of the script...
STRM_N=$(echo $1 | awk '{split($0,array,"/")} END {print array[4]}')
Msg=$(echo Initializing streaming $STRM_N,Please wait 10 seconds... | sed 's/ /%20/g')
curl -m 3 127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn%28Notification%28$Msg%29%29
sleep 10
# Getting current IP address used by $InterfaceName interface
InterfaceName=wlan0
CurrentIP=$(ifconfig $InterfaceName | grep inet | grep -v inet6 | cut -d ":" -f 2 | cut -d " " -f 1)
curl -m 3 127.0.0.1:8080/xbmcCmds/xbmcHttp?command=PlayFile%28http://$CurrentIP:8902/%29
# Control every 5 seconds if the streaming is working, if it's not XBMC will be alerted...
while true
do
if ! ps $SP_SC > /dev/null
then
echo sopcast: sp-sc client stopped working >&2
# If sp-sc exits, it's probably because the streaming stopped working! Anyway you'll see this notification even if another streaming is selected.
Msg=$(echo Error,Streaming $STRM_N stopped working! | sed 's/ /%20/g')
curl -m 3 127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn%28Notification%28$Msg%29%29
exit 1
fi
out=$(curl -m 3 "127.0.0.1:8080/xbmcCmds/xbmcHttp?command=GetCurrentlyPlaying%28%29" | grep Nothing)
if [ "$out" = "<li>Filename:[Nothing Playing]" ]
then
echo sopcast: client-requested sp-sc interruption! >&2
Msg=$(echo Notification,Interruption of $STRM_N streaming completed! | sed 's/ /%20/g')
curl -m 3 127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn%28Notification%28$Msg%29%29
# Close ONLY current sp-sc session, if asked!
kill -9 $SP_SC
exit 1
fi
sleep 5
done
Then you need to make this executable, so let's do something like this in the shell:
Now all is ready, so let's give a little explaination on how the script works: it starts a streaming and asks you to wait 10 secs (so be patient and don't touch anything
, because the script could have strange behaviours if you try to start another streaming for example!) then, if the streaming exists, you should see a loading notification or directly the video streaming (if you have a good connection
). To stop the streaming you have just to stop the player or change streaming, because this one will kill the one you started before!
And this is all!!! If you need something please feel free to post your questions, I will (probably
) answer!! PS: i'm not English, so please be nice with me for my english
!!!