thibauts / node-castv2-client

A Chromecast client based on the new (CASTV2) protocol
MIT License
646 stars 92 forks source link

Is there a way to do local playback? #69

Closed mqbui1 closed 7 years ago

mqbui1 commented 7 years ago

Is there a way to playback videos that is installed locally? For example, I want to be able to cast all the videos in a directory on my raspberry pi.

Any help is appreciated, thanks.

thibauts commented 7 years ago

You can't do it directly. This is totally doable though. You have to expose your files through a static HTTP server and cast your files URLs.

ceberous commented 4 years ago

python -m SimpleHTTPServer

const media_mp3 = {
    contentId: http://$LOCAL_IP:8000/local_audio_file.mp3  ,
    contentType: 'audio/mp3' ,
    streamType: 'BUFFERED' ,
};
ceberous commented 4 years ago

Playing Live Twitch .m3u8 Audio Stream

#!/bin/bash
# ps aux | grep 8000 | tail -1 | awk '{print $2}'
PreviousPID=$(ps aux | grep SimpleHTTPServer | tail -1 | awk '{print $2}')
kill -9 $PreviousPID
python -m SimpleHTTPServer 8000 &
DirectM3U8URL=`youtube-dl -f 'audio_only' -g $1`
# https://github.com/ytdl-org/youtube-dl/issues/18813#issuecomment-453766299
echo $DirectM3U8URL
ffmpeg -i "$DirectM3U8URL" local_audio_file.mp3 -y

./above_script.sh https://twitch.tv/lost_in_house

And then Use:

const media_mp3 = {
    contentId: http://$LOCAL_IP:8000/local_audio_file.mp3  ,
    contentType: 'audio/mp3' ,
    streamType: 'BUFFERED' ,
};

It plays , but you have to keep restarting it after it reaches the end of the mp3.