Project

General

Profile

RE: How to Chromecast? ยป test_stream.py

David G, 2020-02-05 16:19

 
1
#!/usr/bin/python3
2

    
3
import cgi
4
import cgitb
5
import codecs
6
import configparser
7
import datetime
8
import hashlib
9
import json
10
import os
11
import stat
12
import sys
13
import time
14
import collections
15
import socket
16
import urllib
17
import requests
18
import time
19
import pychromecast
20

    
21
chromecasts = pychromecast.get_chromecasts()
22

    
23
####################### Enter friendly name of Chromecast device below #############
24
cast = next(cc for cc in chromecasts if cc.device.friendly_name == "Sun Lounge TV")
25
cast.wait()
26

    
27
mc = cast.media_controller
28

    
29
#TEST FILE;
30
mc.play_media('http://192.168.1.183/Hit Mornings With Pandora.mkv', 'video/mp4')
31

    
32
mc.block_until_active()
33
#time.sleep(9999)
34
#mc.seek(0)
35

    
    (1-1/1)