Comments (26)
I have a come long way, thanks to Michael. There was time when nothing was working for me. Now I am stuck on the last part: how to chrome cast what is dispalying on the client using the cleint.playMEdia(item) call.
from python-plexapi.
This Reddit post doesn't make it sound promising for the Chromecast. -- I believe we would need it to show up in the clients list to even think about getting it to work.
from python-plexapi.
Marking this as an enhancement. If the Plex Web Client and cast to a Chromecast, maybe we can add a new function to cast as well.
from python-plexapi.
I just ordered a Chromecast, excited to make this one work. :P
from python-plexapi.
from python-plexapi.
https://github.com/balloob/pychromecast
from python-plexapi.
Interesting. I was hoping we could add Chromecast support by calling some URL on the Plex Media Server, but that doesn't seem to be the case. When we connect to a Chromecast from the webapp, there is no ajax request sent anywhere, and it all seems to be handled via JS & Chrome Browser. This is also spit out in the logs, which may be useful:
{
"sessionId":"70f76413-f64e-4656-8f4e-43489c2766f3",
"appId":"9AC194DC",
"displayName":"Plex",
"statusText":"Plex",
"receiver":{
"label":"rRckpLGcPLvz4_hkCyoxuFkBPANk.",
"friendlyName":"Chromecast3683",
"capabilities":["video_out","audio_out"],
"volume":{
"controlType":"attenuation",
"level":1,
"muted":false,
"stepInterval":0.05000000074505806
},
"receiverType":"cast",
"isActiveInput":null,
"displayStatus":null
},
"senderApps":[],
"namespaces":[
{"name":"urn:x-cast:com.google.cast.broadcast"},
{"name":"urn:x-cast:com.google.cast.media"},
{"name":"urn:x-cast:plex"}
],
"media":[],
"status":"connected",
"transportId":"70f76413-f64e-4656-8f4e-43489c2766f3"
}
Looking at pychromecast, it seems easy enough to cast. But I wonder what the usefulness is of us adding a function to do the very basic steps they have in their readme. It it worth the 4 extra dependancies just to add a castMedia() function which essentially will do the following:
import pychromecast
def castMedia(media, ccName):
chromecasts = pychromecast.get_chromecasts()
cast = next(cc for cc in chromecasts if cc.device.friendly_name == ccName)
cast.wait()
mc = cast.media_controller
mc.play_media(media.parts[0].file, 'video/mp4')
mc.block_until_active()
return cast, mc
Perhaps the usefulness is auto-starting the next media file when there is more than one part or managing playlists?
from python-plexapi.
Looks like some other people got this working..
https://forum.xda-developers.com/android-tv/chromecast/plex-python-chromecast-t3520651
from python-plexapi.
Can you make a official guide on how to make this work or does the example above work? I don't have chromecast. We could add it to the utility file with a inline import
from python-plexapi.
@pkkid Did you figure out how to cast somthing at chromecast?
from python-plexapi.
I never ended up trying.
from python-plexapi.
I got this working. Ill post an example and create a PR later👍
from python-plexapi.
from python-plexapi.
You can use this branch to test support for chromecast. https://github.com/pkkid/python-plexapi/tree/chromecast
pychromecast does have some deps and are 3.4 only so dunno if we should merge it.
from python-plexapi.
@Hellowlol just wanted to say I've been breaking my head over this for weeks and just stumbled on to this and managed to get your PR working - thank you so much!
from python-plexapi.
@aazimh your welcome. Thanks for testing it 🎉
from python-plexapi.
@Hellowlol Okay, on some further testing maybe things aren't all that perfect :) it appears to work fine if the Plex Chromecast app is already up and running - however, if something else is casting, or even if the Chromecast is idle, all I get is the Plex splash screen saying 'ready to play', but the media in question doesn't end up playing.
I've tried reading through your code to debug it, but don't think I can be much help. All I can think of is adding some sort of delay between launching the Plex app and actually sending the play media command? I tried doing this myself but it looks like the 'play_media' command is what actually launches the app so not possible to add a delay anywhere.
Hope this is useful information for debugging!
from python-plexapi.
This is my code - selection
is the result of a search, and cast
is my Chromecast (these assignments have been made already):
cast.wait()
pc = PlexController()
cast.register_handler(pc)
cast.wait()
pc.play_media(selection)
I know I have an extra wait()
since I thought that might help the Chromecast get ready to receive the play command, but it doesn't seem to make a difference.
from python-plexapi.
My example don’t handle this. That up the user. You can check if the current running app is plex, if not you can launch the app manually then do the play_media. I thought chromecast should handle the running app. Have try tried enabling som logging so you see what happens?
from python-plexapi.
I’m only on mobile atm but is seems like it it’s a bug in the pychomecast send_message, the call_back isn’t used.
from python-plexapi.
So I had some time to dig into this today and I think I have a hacky solution. I used your tip of checking the current app - if it is Plex already, I just use play_media
normally. If not, then I start the app manually, wait 5 seconds (seems to be enough time for it to become ready) and then play_media
and it works :) code below in case it helps:
if cast.status.display_name == 'Plex':
pc = PlexController()
cast.register_handler(pc)
pc.play_media(selection)
else:
cast.start_app('9AC194DC')
pc = PlexController()
cast.register_handler(pc)
cast.wait()
time.sleep(5)
pc.play_media(selection)
I know you mentioned it being a bug in pychromecast not using a callback, and I tried looking into that but it went over my head :) if you're able to crack that I'd be more than happy to test out.
from python-plexapi.
If you ask for the cast.status.display_name
in a loop, will it eventually say 'Plex' when it's ready?
from python-plexapi.
@pkkid Great suggestion :) it's definitely ready in less than 5 seconds so this works a lot better! Code below, but if there's a better way to loop let me know - thanks again for the tip!
if cast.status.display_name == 'Plex':
pc = PlexController()
cast.register_handler(pc)
pc.play_media(selection)
else:
cast.start_app('9AC194DC')
pc = PlexController()
cast.register_handler(pc)
current_app = cast.status.display_name
while current_app != 'Plex':
current_app = cast.status.display_name
time.sleep(1)
pc.play_media(selection)
from python-plexapi.
I’m sure there is a better way to do this. I’ll looking into it when I try to recreate the launch issue.
from python-plexapi.
I have updated the branch with a new method called block_until_playing use this one if you want to ensure that the your program does not exit until the callback is done.
from python-plexapi.
Closing this a my PR was merged in pychromecast
from python-plexapi.
Related Issues (20)
- 4.15.1 breaks setSelectedSubtitleStream due to missing arg (Quick fix!)
- PlexHistory.source() returns Tag class if file has been deleted
- Third-party sign in
- `SmartFilterMixin._parseFilters` algorithm fails when multi-level filters are to be parsed
- Create a Contributing guide for the project HOT 1
- Filter parsing returns unknown keys `group` and `having`
- Code Improvement: Fix class `Playable`
- Code Improvement: Organize Project Structure
- Unable to connect to a Plex HTPC client HOT 3
- Add Type Hints to Improve Codebase Readability and Maintainability HOT 1
- Show and Season from the video module use wrong key to get subtitleLanguage attribute
- Add support for track genres in music libraries HOT 1
- feat: python class for available filters HOT 3
- Add support for Plex Profile Watch History and Ratings
- Library section lookup clobbered when multiple libraries have the same title
- editAlbum Missing ... HOT 1
- Unable to find Libraries after using PlexApi based python script. HOT 5
- locations is empty when casting to dict HOT 2
- Add 'merge' method for music albums
- Ability to Modify MovieHistory & EpisodeHistory details HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-plexapi.