AirPlay target support integrated into XBMC natively?

  Thread Rating:
  • 3 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Closed
logictester Offline
Fan
Posts: 675
Joined: Oct 2008
Reputation: 0
Location: USA
Post: #31
vinc Wrote:http://www.youtube.com/watch?v=2oBfC8Lqumo

Looks SWEET!!!
find
vinc Offline
Junior Member
Posts: 14
Joined: Dec 2010
Reputation: 0
Post: #32
asked for an ETA via Twitter, he said he'll be releasing an alpha version this week.
find
Blieb Offline
Junior Member
Posts: 13
Joined: Dec 2010
Reputation: 0
Post: #33
It's not that hard, I just played with php and make this possible:
http://www.twitvid.com/ORKK0

I tested it only with youtube (why does it not work for the other one?). That works great, but alot problems, can't wait for the alpha Tongue

oh and also the picture vieuwer works, but I don't know how I can let xbmc show a picture via json-rpc Tongue
find
vinc Offline
Junior Member
Posts: 14
Joined: Dec 2010
Reputation: 0
Post: #34
@Blieb, care to share your php code? Would be interesting to see how you'd implement it using php! (ps; dutch?)
find
iapiap Offline
Junior Member
Posts: 2
Joined: Dec 2010
Reputation: 0
Post: #35
@Blieb, I would also like to take a look at your code if possible, please Smile Thanks!
find
htpc guy Offline
Posting Freak
Posts: 1,213
Joined: Oct 2010
Reputation: 7
Location: Near St. Louis Mo
Post: #36
Hay, this is on Engadget!
http://www.engadget.com/2010/12/21/airpl...ext-video/


Congrats!

How to use Git
| AMD Athlon II X3 Triple Core Processor 2.9 GHz |GIGABYTE GA-MA785GM-US2H Mobo 2GB DDR2 Ram | MSI N430GT |
| Logitec Harmony One Remote| 52" Sharp Aquos LED TV | Onkyo TX-NR509 |
find
Blieb Offline
Junior Member
Posts: 13
Joined: Dec 2010
Reputation: 0
Post: #37
iapiap Wrote:@Blieb, I would also like to take a look at your code if possible, please Smile Thanks!

Sure, but is it very buggy, I think this is not a good language voor making airplay in it.

PHP Code:
<?php
error_reporting
(E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);

/* Turn on implicit output flushing so we see what we're getting
 * as it comes in. */
ob_implicit_flush();

$sendok "HTTP/1.1 200 OK\nContent-Length: 0\n\n";

$address '192.168.0.60';
$port 22555;

if ((
$sock socket_create(AF_INETSOCK_STREAMSOL_TCP)) === false) {
    echo 
"socket_create() failed: reason: " socket_strerror(socket_last_error()) . "\n";
}

if (
socket_bind($sock$address$port) === false) {
    echo 
"socket_bind() failed: reason: " socket_strerror(socket_last_error($sock)) . "\n";
}

if (
socket_listen($sock5) === false) {
    echo 
"socket_listen() failed: reason: " socket_strerror(socket_last_error($sock)) . "\n";
}

do {
    if ((
$msgsock socket_accept($sock)) === false) {
        echo 
"socket_accept() failed: reason: " socket_strerror(socket_last_error($sock)) . "\n";
        break;
    }
    
/* Send instructions. */

    
do {
        if (
false === ($buf socket_read($msgsock2048PHP_NORMAL_READ))) {
            echo 
"socket_read() failed: reason: " socket_strerror(socket_last_error($msgsock)) . "\n";
            break;
        }
        if (!
$buf trim($buf)) {
            continue;
        }
        echo 
"'$buf'\n";
        
$expl explode(" "$buf);
        if (
$expl[0] == "POST") { $cmd $expl[1]; $method $expl[0]; }
        if (
$expl[0] == "PUT") { $cmd $expl[1]; $method $expl[0]; }
        if (
$expl[0] == "GET") { $cmd $expl[1]; $method $expl[0]; }
        if (
$expl[0] == "Content-Location:") { $url $expl[1]; }
        if (
$expl[0] == "Content-Length:") { $contentlength $expl[1]; }
        if (
$expl[0] == "Start-Position:") { 
                
$postition $expl[1];
                echo 
"- Ik moet $url spelen!";
                
startvideo($url);
                
socket_write($msgsock$sendok);
        }

        if (
$expl[0] =="User-Agent:") {
                echo 
substr($cmd0,6);
                if (
$cmd == "/photo") {
                        
$photo "";
                        while (
strlen($photo) < $contentlength) {
                                
$photo .= socket_read($msgsock$contentlength);
                                echo 
"  -foto ontvangen" strlen($photo) . " of " $contentlength "\n"
                        }
                        
$File "/var/www/test.jpg"
                        
$Handle fopen($File'w');
                        
fwrite($Handletrim($photo)); 
                        
fclose($Handle);
                        
$cmd "";
                        
startpic("http://192.168.0.60/test.jpg");
                        
socket_write($msgsock$sendok);
                }
                if (
substr($cmd0,6) == "/scrub") {
                        
socket_write($msgsock$sendok);
                        echo 
"- send scrub reply\n";
                }
                if (
substr($cmd0,5) == "/rate") {
                        
$body "duration: 2:23\nposition: 31:11\n";
                        
$length strlen($reply);
                        
$reply "HTTP/1.1 200 OK\nContent-Length: $length\n\n";
                        
socket_write($msgsock$reply "\n\n" $body "\n\n");
                        echo 
"- send rate reply\n";
                }
                if (
$cmd == "/reverse") {
                {
                        
$reply "HTTP/1.1 101 Switching Protocols\r\nUpgrade: PTTH/1.0\r\nConnection: Upgrade\r\n\r\n\r\n";
                        
socket_write($msgsock$reply);
                        echo 
"- Sending switchting protocols\n";
                        
$cmd "";
                }
                break;
        }
        }

    } while (
true);
    
socket_close($msgsock);
} while (
true);

socket_close($sock);

function 
startvideo($url) {
system("curl -i -X POST -d '{\"jsonrpc\": \"2.0\", \"method\": \"XBMC.Play\", \"params\":{ \"file\" : \"" $url "\" }, \"id\": 1}' http://192.168.0.63:8080/jsonrpc");
}
function 
startpic($url) {
system("curl -i -X POST -d '{\"jsonrpc\": \"2.0\", \"method\": \"XBMC.Play\", \"params\":{ \"file\" : \"" $url "\" }, \"id\": 1}' http://192.168.0.63:8080/jsonrpc");
}
?>
avahi service file:

Code:
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_airplay._tcp</type>
<port>22555</port>
</service>
</service-group>


I was running the script on a other computer than xbmc is running. when used for photo's it saves photo to /var/www/test.jpg but I dit not know how to show it in xbmc.

I know it is crapy code. but it was just for testing. It should be written in a real language Tongue
find
Jaken Online
Senior Member
Posts: 156
Joined: Nov 2009
Reputation: 0
Post: #38
What about support for xbmc-to-ATV2G airplay. Is there hope for this? That would make these tiny black boxes do something useful. =)
find
iapiap Offline
Junior Member
Posts: 2
Joined: Dec 2010
Reputation: 0
Post: #39
Thanks @Blieb, that's very interesting - thanks for sharing.
find
JaccoH Offline
Member
Posts: 79
Joined: May 2009
Reputation: 0
Post: #40
@Blieb I've tried your code. It works. As far as I can tell only from youtube videos on my iPhone though. I would love for this to support audio as well. Would that be hard?
find
Thread Closed