Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/ryanhefner/googlecast-wrappers
- Owner: ryanhefner
- Created: 2015-02-18T02:30:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-26T19:27:20.000Z (almost 9 years ago)
- Last Synced: 2023-08-04T13:56:53.704Z (about 1 year ago)
- Language: JavaScript
- Homepage: labs.ryanhefner.com/open-source/googlecast-wrappers
- Size: 182 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 Mediavar 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
});```