Airplay Plugin for Plex

Just wanted to post a thank you as well. Works perfect for me with the exception of the initial stuttering/buffering thing. Fantastic stuff!



I think it's related to the video or audio codec used in certain movies. For me, the stuttering only happens when I play a movie from iTunes on my iPhone. It doesn't happen with movies from the Youtube app, nor with movies from my camera roll (on IOS 4.3 beta).

I just tested it and it stutters from youtube too. I can't test it with 4.3 but with 4.2.1 it stutters with every movie except the photo stream (no audio).

For me it looks like it doesn't cache enough and as soon as it runs out of cache it replays until it has enough video. It might help to buffer more if that's possible.


I doesn't have this issue. Can you try to close all the running apps and restart your iPhone and report back ?

And also restart you Mac at the same time.

I already tried that. I'm using an iPod touch. With this Airplayer however it works without any issues: http://ericasadun.com/ftp/AirPlay/AirPlayer-0.27.zip

I’m finding that when I try to send media using my iPhone, Plex will crash. Plex reports that it is buffering, and the console running the Airplayer script is just reporting “[INFO] GET /scrub” every second. I’ve left it for a while and nothing appears to happen. Has anyone else seen this?



Ah, just noticed some additional debug information:



2011-01-15 15:49:26 [DEBUG] Setting start position failed: <ProtocolError for username:password@127.0.0.1:3000/jsonrpc: 404 Site or Page Not Found>

DEBUG:airplayer:Setting start position failed: <ProtocolError for username:password@127.0.0.1:3000/jsonrpc: 404 Site or Page Not Found>

2011-01-15 15:49:27 [WARNING] Failed to set start position

WARNING:airplayer:Failed to set start position



Airplayer from Erica Sadun uses an embedded Quicktime player which is probably better than Plex at handling the codec used by movies from the iTunes Store for example.

When you send a movie through Airplay, only an url is send to the Airplay client. The media player is then responsible for playing the movie from that url, there's nothing Airplayer can do about that.



You should set MEDIA_BACKEND = 'Plex' in settings.py, it seems you have set it to 'XBMC'.

Alright thanks. It seems it needs to be fixed within Plex. I can't test it but will this happen too by opening any other stream url? Maybe Plex doesn't have any buffer or it is too short.


Thanks for that, I gave it a go. However, I'm now getting another exception in the debug output. It says "Buffering" and reaches the end of the progress bar, but nothing starts...

ERROR:root:Uncaught exception GET /scrub (10.0.1.15)
HTTPRequest(protocol='http', host='127.0.0.1', method='GET', uri='/scrub', version='HTTP/1.1', remote_ip='10.0.1.15', remote_ip='10.0.1.15', body='', headers={'Content-Length': '0', 'User-Agent': 'MediaControl/1.0'})
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/tornado/web.py", line 810, in _stack_context
yield
File "/Library/Python/2.6/site-packages/tornado/stack_context.py", line 77, in StackContext
yield
File "/Library/Python/2.6/site-packages/tornado/web.py", line 827, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "/Users/Ian/Applications/Airplayer/airplayer/protocol_handler.py", line 121, in get
position, duration = self._media_backend.get_player_position()
File "/Users/Ian/Applications/Airplayer/airplayer/mediabackends/Plex_media_backend.py", line 168, in get_player_position
total = utils.duration_to_seconds(total_str)
File "/Users/Ian/Applications/Airplayer/airplayer/utils.py", line 37, in duration_to_seconds
raise Exception('Invalid value supplied: %s', duration_str)
Exception: ('Invalid value supplied: %s', '')

I'm sorry i'm not normally this useless. I've also been trying to get this working on my MBP and finding that when I attempt to do "pip install -r requirements.txt", the pip output complains about not being able to find gcc. Is there a simple way around this?

Thanks (and sorry again)

Good news, I’ve just fixed a bug in the Plex media backend which should fix the stuttering. I thought you were experiencing a codec issue, but turns out there was a bug which could have caused it too.



Could people who expierenced the stuttering get the latest version from Github and see if it fixes the problem? Thanks.



Just tested it and it works without any stuttering!

Thanks for that!

Works great. No stuttering anymore.

Good to hear that guys.

I updated to the latest version from GitHub and tried various files and found that I only have issues playing content which has been purchased via iTunes. For example, I have some of my own movies which have been converted to mp4 and uploaded to my iPhone, these play fine. Also, media played via You Tube also plays fine. However, I got some iTunes videos (during Apples 12 days of christmas free giveaway) that does not want to play. Is this expected?



I’m also having issues installing it on my MacBook Pro. Since i’ve not installed any development environments (xCode) it doesn’t seem to have gcc installed (or locatable). Therefore, when i attempt to install the requirements, Im getting complaints that it can’t compile simplejson. Is there anyway around this without installing XCode, etc?



Yes, as pointed out in the [readme](https://github.com/PascalW/Airplayer/blob/master/README.mdown), DRM protected content cannot be played through Airplayer.

You should be able to install simplejson without having a C compiler, it just won't install the C extensions which makes it a bit slower. Are you sure it fails installing?


Of course, you are completely right, and i'm now embarrassed! Works like a dream. Thanks again for such a great feature (and all of the help!)


DRM replay does only work with Apples QuickTime-player. So if you really need to have it on the screen you can use Airplayer from Erica Sadun. It opens a QT window which should play your content too. But this would mean you can't use it while you are in Plex.

[http://ericasadun.co...Player-0.27.zip](http://ericasadun.com/ftp/AirPlay/AirPlayer-0.27.zip)


Thanks for that. I've actually been using AirPlayer and AirFlick for some time. However, I like the idea of having all these features (and others) integrated into a single system. Plex seems to be ideal and should hopefully just get better.

Two bits of good news!

  1. I’ve written a nifty bit of JS to allow anyone to use Plex with AirFlick! Documentation is here: http://www.twitlonger.com/show/85tl9v
  2. Plex devs: Open the url “airflick://play-media?MediaLocation=http://plex_server:port/my_transcoded_file.mp4” to send any media file to AirFlick. I hope to see this either builtin or in a plugin soon.

Hi PascalW,



Thanks for writing this excellent script. I got it working by running it manually in terminal, but I can’t seem to get it running in the background.



So far here is what I did:


  1. Placed the airplayer.py in /Applications/PascalW-Airplayer-7b7b1c5/airplayer/airplayer.py
  2. Ran it manually in Terminal to make sure it works, pristine!
  3. Copied org.pwiddershoven.airplayer.plist to /Users/myaccount/Library/LaunchAgents
  4. Edited org.pwiddershoven.airplayer.plist as following:



<?xml version="1.0" encoding="UTF-8"?><br />
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><br />
<plist version="1.0"><br />
<dict><br />
    <key>Disabled</key><br />
    <false/><br />
    <key>Label</key><br />
    <string>org.pwiddershoven.airplayer</string><br />
    <key>ProgramArguments</key><br />
    <array><br />
        <string>/Applications/PascalW-Airplayer-7b7b1c5/airplayer/airplayer.py</string><br />
        <string>--logfile</string><br />
        <string>~/Library/Logs/airplayer.log</string><br />
    </array><br />
    <key>RunAtLoad</key><br />
    <true/><br />
    <key>OnDemand</key><br />
    <true/><br />
</dict><br />
</plist>



5. Terminal: *launchctl load -w /Users/myaccount/Library/LaunchAgents/org.pwiddershoven.airplayer.plist* - which gave me this error:


launchctl: Dubious permissions on file (skipping): /Users/myaccount/Library/LaunchAgents/org.pwiddershoven.airplayer.plist<br />
nothing found to load<br />




6. Terminal: *launchctl start org.pwiddershoven.airplayer* - which gave me this error:


launchctl start error: No such process




**After this I tried doing the following:**

* chmodding both org.pwiddershoven.airplayer.plist and airplayer.py with +x
* Replacing the string in step 4 with /Applications/PascalW-Airplayer-7b7b1c5/airplayer/ [s](is this the proper way btw, a bit unclear?)[/s] Updated: the proper way is as above [for future reference]
* placing the folder on my desktop instead of in /Applications/ and making the necessary adjustments
* each time I made a change I logged out and then in again

But nothing seems to help.

I am running 10.6.6, any advice would be hugely appreciated!

Thanks again for this awesomeness.