Set up sopcast player as an external player for plugin

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Hudson_Hawk04 Offline
Posting Freak
Posts: 1,173
Joined: Oct 2006
Reputation: 3
Post: #1
Hey all, I was wondering if someone could offer me a few pointers on how to get a sop cast player specifically sopcast-player (http://code.google.com/p/sopcast-player/) working as an external player for the sports devil plugin, running on ubuntu 11.04, I am at a loss at the moment.

Thanks for any help in this matter.

I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day.
Frank Sinatra
If I managed to help you in any way, please add to my reputation
.
find quote
deckoff Offline
Member
Posts: 56
Joined: Apr 2011
Reputation: 0
Location: Sofia, BG
Post: #2
I am trying to do the same. Did anyone find a solution for this?
(This post was last modified: 2012-02-02 14:38 by deckoff.)
find quote
deckoff Offline
Member
Posts: 56
Joined: Apr 2011
Reputation: 0
Location: Sofia, BG
Post: #3
How to use sopcast and vlc for external player in XBMC with Sportsdevil

VLC has to be installed!!!

Intsall command-line sopcast, follow this link
http://www.sopcast.org/download/
Add libstdcpp5 if needed.

Download the command-line file from official site and copy it to /usr/bin.


Create a new text file, and copy the following to it. Be sure to mark the file as executable. Copy the file to /usr/bin. the name should be sopcast (case-sensitive)

Code:
#!/bin/sh
# Start streaming sopcast address $1 with sp-sc-auth, then start VLC and monitor both processes.
# Author: Chickamade <anh.chick@gmail.com>

if ! test $# -eq 1
then
    echo 'Usage: sopcast <sop://address>'
    exit 0
fi

if pgrep -f "sp-sc-auth $1"
then
    echo sopcast: channel $1 already streaming, quitting >&2
    exit 0
fi

PORT=${1##*/}

#some modifications done by Stoyan Deckoff <deckoff@gmail.com>
#This edit ensures port number at which sopcast is streaming is between 10000-100000
#Otherwise vlc will fire an error
while [ $PORT -gt 100000 ]
do
PORT=$(($PORT-100000))
done

if [ $PORT -lt 10000 ]
then
PORT=$(($PORT+10000))
fi


#echo $PORT
#End of Stoyan Deckoff modifications

echo sopcast: starting stream $1 on port $PORT >&2
sp-sc-auth "$1" 3908 $PORT >/dev/null &
SP_SC=`pgrep -f "sp-sc-auth $1 3908 $PORT"`
if test -z $SP_SC
then
    echo sopcast: stream $1 failed to start >&2
    exit 1
fi

sleep 20

vlc http://localhost:$PORT/tv.asf >/dev/null 2>&1 &
VLC=`pgrep -f "vlc http://localhost:$PORT/tv.asf"`
if test -z $VLC
then
    echo sopcast: VLC failed to start >&2
    kill -9 $SP_SC
    exit 1
fi

while true
do
    if ! ps $SP_SC > /dev/null
    then
        echo sopcast: stream $1 died, killing VLC >&2
        kill $VLC
        exit 1
    fi
    if ! ps $VLC > /dev/null
    then
        echo sopcast: VLC not running, killing stream $1 >&2
        kill -9 $SP_SC
        exit 0
    fi
    sleep 10
done
exit 0


This sh file is slightly modified version of sopcast.sh, found here

In your ~/xbmc/userdata one should modify the playercorefactory.xml, or create a new one, with this contend added

Code:
<playercorefactory>
<players>
   <player name="Sopcast" type="ExternalPlayer" audio="false" video="true">
     <filename>/usr/bin/sopcast</filename>
    <args>"{1}"</args>
     <hidexbmc>false</hidexbmc>
     <hideconsole>true</hideconsole>
   </player>
</players>
<rules action="prepend">
   <rule protocols="sop" player="Sopcast"/>
</rules>
</playercorefactory>

restart XBMC.

This works for me on Xubuntu 11.04 and Xbmc 10.1 stable

A few notes: Please wait for the stream to start. If the strwam fails, vlc window will show for a fraction of a second. Wait for this to happen before trying with a new stream.
The stream will be re-directed to VLC, so the controls of VLC should be used
PS - The sopcast script was edited, so more that one stream is possible at the time. Best thing about it is that if sopcast strwam hangs and is not auto killed, this will not stop new streams for opening in VLC. In two words: use this ! Smile
(This post was last modified: 2012-02-20 22:52 by deckoff.)
find quote
orduek Offline
Member
Posts: 94
Joined: Dec 2008
Reputation: 0
Post: #4
Thank you very much for this.
I do have one question-- Is it possible to use it as an embedded player. Now it opens VLC which I have no remote control over it (so I have to get up and use the mouse etc.)
find quote
deckoff Offline
Member
Posts: 56
Joined: Apr 2011
Reputation: 0
Location: Sofia, BG
Post: #5
orduek Wrote:Thank you very much for this.
I do have one question-- Is it possible to use it as an embedded player. Now it opens VLC which I have no remote control over it (so I have to get up and use the mouse etc.)

I provided only the how-to. The author of the plug-in states that sopcast must be configured with an external player, so I assume the answer is no.
BTW, I think the best remote for XBMC is a small usb no-cable keyboard, I got one (with a mouse included for under 20$, which is a reasonable price) think about it. Smile
Glad I helped in a way and you got it working, thoug Smile
find quote
losifabio Offline
Junior Member
Posts: 3
Joined: Mar 2012
Reputation: 0
Post: #6
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 Sad, 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 Wink!

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:

Code:
chmod +x sopcast

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 Big Grin, 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 Wink). 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 Tongue) answer!! PS: i'm not English, so please be nice with me for my english Big Grin!!!
find quote
oligolli Offline
Junior Member
Posts: 13
Joined: Jun 2011
Reputation: 0
Post: #7
Brilliant! Thanks very much for sharing losifabio Smile
find quote
Steve Jol Offline
Junior Member
Posts: 22
Joined: Apr 2011
Reputation: 0
Post: #8
losifabio....my hero!
find quote
deckoff Offline
Member
Posts: 56
Joined: Apr 2011
Reputation: 0
Location: Sofia, BG
Post: #9
Faith in humanity restored!!! Smile
To get it straight - you send the correct sopcast link to sp-sc-auto, then the script tells xbmc to open it as a network stream, am I getting it right? Splendid !!!!
find quote
konti Offline
Junior Member
Posts: 48
Joined: May 2005
Reputation: 0
Post: #10
Thnx losifabio. I've added the username/password variables for the people who do not know how to do this.

Mine looks like this now:

Code:
#!/bin/sh
# Script for utilize Sopcast with XBMC
XBMCUSER="xbmc"
XBMCPASS="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 $XBMCUSER:$XBMCPASS@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 $XBMCUSER:$XBMCPASS@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 $XBMCUSER:$XBMCPASS@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=eth0
CurrentIP=$(ifconfig $InterfaceName | grep inet | grep -v inet6 | cut -d ":" -f 2 | cut -d " " -f 1)
curl -m 3 $XBMCUSER:$XBMCPASS@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 $XBMCUSER:$XBMCPASS@127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn%28Notification%28$Msg%29%29
        exit 1
    fi

    out=$(curl -m 3 "$XBMCUSER:$XBMCPASS@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 $XBMCUSER:$XBMCPASS@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
find quote