Skip to content

Commit 371a981

Browse files
committed
Update Chromecast-main.py
1 parent a91a83e commit 371a981

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Chromecast-main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def start_cast(stop_connection = False):
3636
pass
3737

3838
# Share an image (from a URL) to the Chromecast
39-
def show_media(url, temp=10):
39+
def show_media(url, x=0, duration=10): #duration is in seconds, by default set at 10 (for mp4)
4040
global cast
4141
global mc
4242
mc = cast.media_controller
@@ -48,7 +48,12 @@ def show_media(url, temp=10):
4848
elif "mp4" in url:
4949
mc.play_media(url, 'video/mp4')
5050
mc.block_until_active()
51-
time.sleep(int(Medias[temp][1]))
51+
if Medias[x][1] != "":
52+
duration = int(Medias[x][1])
53+
print("Found duration in csv file", duration ,"s)")
54+
else:
55+
print("No duration found in csv file, set to default (", duration ,"s)")
56+
time.sleep(int(duration))
5257

5358
else:
5459
mc.play_media(url, 'image/jpeg')

0 commit comments

Comments
 (0)