Skip to content

Latest commit

 

History

History
139 lines (106 loc) · 7.58 KB

README.md

File metadata and controls

139 lines (106 loc) · 7.58 KB

Fling

The Fling application allows you to beam video files from computers to ChromeCast devices.

To run the application, you need a Java runtime environment (JRE) for your operating system.

Fling no longer works for the public since the public ChromeCast app receiver no longer allows video playback.

There is a dependency on a web app that needs to be registered with Google.

When the application starts, it will search for ChromeCast devices on your local network. Select the device that you want to beam the videos to. Then drag-and-drop a video file onto the application to beam it to the ChromeCast device.

ChromeCast devices only support a very limited number of media formats. Fling has experimental support for converting other media formats into WebM using the vlcj library for VLC. You need to download and install VLC for your computer (the latest 64-bit version is preferred). For Windows, you need to install the 64-bit experimental version. If you have the 64-bit version of Java, you have to install the 64-bit version of VLC. Click on the Fling Settings button to configure which file formats to convert and to configure the VLC transcoding parameters. By default Fling uses the following VLC transcoding parameters:

:sout=#transcode{vcodec=VP80,vb=1000,vfilter=canvas{width=640,height=360}, acodec=vorb,ab=128,channels=2,samplerate=44100,threads=2} :http{mux=webm,dst=:8087/cast.webm} :sout-keep
Note that converting video is very CPU intensive. It might take several seconds for the video to start playing on your ChromeCast device.

There are basic playback controls to play, pause and stop the video (pause and stop behaves the same). The playback slider/scrubber control does not work for transcoded video.

The computer running the Fling application needs to be on the same network as the ChromeCast device. To play the video, a web server is created on port 8080 on your computer and you might have to configure your firewall to allow incoming connections to access the video.

Note for developers: If you want to use your own receiver, you need to put your own app ID in the FlingFrame.java and receiver index.html files. If you don't want to compile your own version, use this copy of fling.jar and pass in the app ID as the command-line parameter:

java -jar fling.jar xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Watch this video to see the application in action.

Other apps developed by Entertailion:

Building & Running (with Maven)

git clone github.com/entertailion/Fling # get the code
cd Fling
mvn package # maven will get dependencies & build everything
java -jar target/Fling-0.0.1-SNAPSHOT-jar-with-dependencies.jar # run it!

RAMP Protocol for ChromeCast Explained (unofficial):

Google is using a proprietary protocol called RAMP (Remote Application Media Protocol) to control media playback on a ChromeCast device.

The RAMP commands are sent over a web socket connection to the ChromeCast device using JSON notation. Look at my DIAL app that I have open sourced for the sequence of HTTP actions to get the URL for creating the web socket: https://github.com/entertailion/DIAL

Associated with your app you need a receiver HTML page that has a video HTML tag and the Cast receiver javascript library included (same as the Cast SDK sample). You have to start the app associated with the receiver HTML.

Once you have the web socket connection open to the ChromeCast device, there are various commands that allow you to load and control media playback.

The first message you have to deal with is a ping from the device:

["cm",{"type":"ping"}]
The client needs to respond with a "pong" on an interval that is specified with the web socket URL payload:
["cm",{"type":"pong"}]

To load a video use the following RAMP command:

["ramp",{"title":"Video title","src":"http://some/url/to/a/video.mp4","type":"LOAD","cmd_id":0,"autoplay":true}]

The "cmd_id" parameter increments with each command sent from the client. The associated response from the ChromeCast device will have the same "cmd_id" value.

You can use the following command to explicitly ask for status:

["ramp",{"type":"INFO","cmd_id":1}]

However, during my testing the device automatically provided regular status responses during media playback to track the playback progress:

["ramp",{"cmd_id":2,"type":"STATUS","status":{"event_sequence":7768, "state":2, "content_id":"http://some/url/to/a/video.mp4", "current_time":9.208321571350098, "duration":596.5013427734375, "volume":0.5, "muted":false, "time_progress":true, "title":"Video title"}}]

To stop the video:

["ramp",{"type":"STOP","cmd_id":3}]

There doesn't appear to be a pause command. The stop commands actually pauses the video and the user will see a frozen video frame.

To play the video again, you can just play from the current position:

["ramp",{"type":"PLAY","cmd_id":4}]

Or you can start from another position like the beginning of the video:

["ramp",{"position":0,"type":"PLAY","cmd_id":5}]

You can set the volume using the following command:

["ramp",{"volume":0.5,"type":"VOLUME","cmd_id":6}]

Or mute the volume:

["ramp",{"type":"VOLUME","cmd_id":7,"muted":true}]