Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryanhefner/googlecast-wrappers

Simplifying the creation of Google Cast (Chrome) Sender and Receiver apps.
https://github.com/ryanhefner/googlecast-wrappers

Last synced: 2 days ago
JSON representation

Simplifying the creation of Google Cast (Chrome) Sender and Receiver apps.

Awesome Lists containing this project

README

        

# Google Cast - Wrappers

Simple wrappers for Google Cast (Chrome) Sender apps and custom Receiver apps.

It is licensed under the Apache 2.0 license.

## Getting Started (Requirements)
Depending on which one you are planning on building, either a Chrome Sender or a custom Receiver app, here are the basic things that you need to do to get up and running.

### Chrome Sender
In order to create a Chrome Sender app, you'll need to include the following script files in your sender page:

```

```

__NOTE__: `Object.assign()` is used to merge options passed to the `new CastSender({...})` with the default `options` in the sender. Use the supplied polyfill `libs/polyfills/object-assign-polyfill.js` to provide support across all browsers.

### Custom Receiver
For Custom Receiver apps, include the following script files in your receiver app page:

```

```

__NOTE__:
* The `media_player.js` file is only required if you plan to support media playback in your receiver app via the standard media controls.
* `Object.assign()` support is required for the `CastReceiver` object (same as above).

## Simple Example
Here are some super simple examples of the basic requirements for creating a Chrome Sender and Custom Receiver app. For more details examples, review the examples supplied in the `examples` directory.

>NOTE: I am trying to resolve an issue with the custom `Player` interface (`vimeo-player-interface.js`) which is not returning an instance of the media session back to the Sender app. Once resolved, the supplied example should be working and usable.

### Chrome Sender
```
Cast
Load Media

var castButton = document.getElementById('cast-button'), // Hidden by default
loadButton = document.getElementById('load-button'),
sender = new CastSender({
appId: [YOUR APP ID or chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID],
customNamespace: 'urn:x-cast:com.your.app', // Only required if you plan to send custom messages to your receiver app
onReceiverAvailable: receiverAvailableHandler,
onSessionConnected: sessionSuccessHandler
});

castButton.addEventListener('click', function(ev) {
sender.requestSession(sessionSuccessHandler);
});

loadButton.addEventListener('click', function(ev) {
sender.loadMedia({
contentId: [VIDEO URL]
});
});

function receiverAvailableHandler() {
// Show the castButton since there is a receiver available
castButton.style.display = 'inline-block';
}

function sessionSuccessHandler() {
// Change the state of the cast button when a session has been successfully initiated
castButton.classList.add('active');
}

```

### Custom Receiver
```

var video = document.getElementById('video-tag'),
receiver = new CastReceiver({
appId: [YOUR APP ID],
mediaElement: video
});

```