-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add bubbleupnp media controller * Fix argument names * Linter fixes
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
Example on how to use the BubbleUPNP Controller | ||
""" | ||
import logging | ||
import sys | ||
from time import sleep | ||
|
||
import pychromecast | ||
from pychromecast.controllers.bubbleupnp import BubbleUPNPController | ||
|
||
|
||
# Change to the name of your Chromecast | ||
CAST_NAME = "Kitchen speaker" | ||
|
||
URL = "https://c3.toivon.net/toivon/toivon_3?mp=/stream" | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
# pylint: disable=unbalanced-tuple-unpacking | ||
chromecasts, browser = pychromecast.get_listed_chromecasts(friendly_names=[CAST_NAME]) | ||
if not chromecasts: | ||
print('No chromecast with name "{}" discovered'.format(CAST_NAME)) | ||
sys.exit(1) | ||
|
||
cast = list(chromecasts)[0] | ||
# Start socket client's worker thread and wait for initial status update | ||
cast.wait() | ||
|
||
bubbleupnp = BubbleUPNPController() | ||
cast.register_handler(bubbleupnp) | ||
bubbleupnp.launch() | ||
bubbleupnp.play_media(URL, "audio/mp3", stream_type="LIVE") | ||
cast.wait() | ||
|
||
sleep(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Simple Controller to use BubbleUPNP as a media controller. | ||
""" | ||
|
||
from ..config import APP_BUBBLEUPNP | ||
from .media import MediaController | ||
|
||
|
||
class BubbleUPNPController(MediaController): | ||
""" Controller to interact with BubbleUPNP app namespace. """ | ||
|
||
# pylint: disable=useless-super-delegation | ||
def __init__(self): | ||
super(BubbleUPNPController, self).__init__() | ||
self.app_id = APP_BUBBLEUPNP | ||
self.supporting_app_id = APP_BUBBLEUPNP | ||
|
||
def quick_play(self, media_id=None, media_type="video/mp4", **kwargs): | ||
""" Quick Play """ | ||
self.play_media(media_id, media_type, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters