All Projects → castjs → Castjs

castjs / Castjs

📺 Chromecast Sender Library for the Browser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Castjs

Bw plex
binge watching for plex
Stars: ✭ 322 (+187.5%)
Mutual labels:  chromecast
C8tsender
c8tsender is a Google Chromecast sender server with a built-in REST API and responsive playlist interface
Stars: ✭ 29 (-74.11%)
Mutual labels:  chromecast
Addon Aircast
AirCast - Home Assistant Community Add-ons
Stars: ✭ 100 (-10.71%)
Mutual labels:  chromecast
Chromecast mpris
📺 Control Chromecasts from Linux and D-Bus
Stars: ✭ 413 (+268.75%)
Mutual labels:  chromecast
Appleevents
The unofficial Apple Events app for macOS
Stars: ✭ 831 (+641.96%)
Mutual labels:  chromecast
Opencastswift
An open source implementation of the Google Cast SDK written in Swift
Stars: ✭ 83 (-25.89%)
Mutual labels:  chromecast
Pi-OpenCast
📺 Transform your Raspberry Pi into an awesome streaming device.
Stars: ✭ 29 (-74.11%)
Mutual labels:  chromecast
Multicast Relay
Relay multicast and broadcast packets between interfaces.
Stars: ✭ 111 (-0.89%)
Mutual labels:  chromecast
Audio Cast Radio
Play some radio stations on Chromecast/Chromecast Audio
Stars: ✭ 12 (-89.29%)
Mutual labels:  chromecast
Chromecastcore
An open source implementation of the Google Cast SDK for macOS
Stars: ✭ 95 (-15.18%)
Mutual labels:  chromecast
React Native Google Cast
React Native wrapper for the Google Cast SDK
Stars: ✭ 475 (+324.11%)
Mutual labels:  chromecast
Soundcast
Cast audio from macOS to Chromecast
Stars: ✭ 684 (+510.71%)
Mutual labels:  chromecast
Gnomecast
Chromecast local files from Linux - supports MKV, subtitles, 5.1 sound and 4K!
Stars: ✭ 1,319 (+1077.68%)
Mutual labels:  chromecast
Go Chromecast
cli for Google Chromecast, Home devices and Cast Groups
Stars: ✭ 325 (+190.18%)
Mutual labels:  chromecast
Alexacast
Chromecast support for Amazon Alexa
Stars: ✭ 109 (-2.68%)
Mutual labels:  chromecast
Noice
A native Android app to relax, improve focus and boost productivity with minimal background noise.
Stars: ✭ 264 (+135.71%)
Mutual labels:  chromecast
Homeassistant Config
My personal Home Assistant config
Stars: ✭ 66 (-41.07%)
Mutual labels:  chromecast
Tizonia Openmax Il
Command-line cloud music player for Linux with support for Spotify, Google Play Music, YouTube, SoundCloud, TuneIn, iHeartRadio, Plex servers and Chromecast devices.
Stars: ✭ 1,556 (+1289.29%)
Mutual labels:  chromecast
Anexplorer
📁 Another Android Explorer ( File Manager ) is an All-in-One Open source file manager. AnExplorer File Manager (File Explorer) is designed for all android devices including Phones, Phablets, Tablets, Chromecast, Wear OS, Android TV and Chromebooks. It's a fully designed with Material guidelines by Google.
Stars: ✭ 1,505 (+1243.75%)
Mutual labels:  chromecast
Fx cast
Implementation of the Google Cast Chrome Sender SDK within Firefox
Stars: ✭ 1,319 (+1077.68%)
Mutual labels:  chromecast

Castjs

Javascript library for the complex chromecast SDK

Castjs provides simple events and functions to communicate with chromecast devices from the browser.
This library works in chrome, opera, brave and vivaldi, see it in action and check out the online demo.

Getting Started

Include the cast.min.js from cdnjs:

<script src="https://cdnjs.cloudflare.com/ajax/libs/castjs/4.1.2/cast.min.js"></script>

Getting Started

Casting a media source to your chromecast device.

<button id="cast">Cast</button>

<script src="https://castjs.io/cast.min.js"></script>
<script>
// Create new Castjs instance
const cjs = new Castjs();

// Wait for user interaction
document.getElementById('cast').addEventListener('click', function() {
    // Check if casting is available
    if (cjs.available) {
        // Initiate new cast session
        cjs.cast('https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Sintel.mp4');
    }
});
</script>

Supported Browsers

Almost any Chromium based browser supports cast framework out of the box. Vivaldi Brave

API Documentation:
// Default instance
const cc = new Castjs();

// Custom receiver or joinpolicy
const cc = new Castjs({
    receiver  : 'CC1AD845',              // default
    joinpolicy: 'tab_and_origin_scoped', // default
//  joinpolicy: 'custom_controller_scoped',
//  joinpolicy: 'origin_scoped',
//  joinpolicy: 'page_scoped',
});

// Castjs Events
cjs.on('available',    ()  => {});  // Casting is available
cjs.on('connect',      ()  => {});  // Connected with device
cjs.on('disconnect',   ()  => {});  // Disconnected with device
cjs.on('statechange',  ()  => {});  // Device state
cjs.on('timeupdate',   ()  => {});  // Current time changed
cjs.on('volumechange', ()  => {});  // Volume changed
cjs.on('mute',         ()  => {});  // Muted state changed
cjs.on('unmute',       ()  => {});  // Muted state changed
cjs.on('playing',      ()  => {});  // Media is playing
cjs.on('pause',        ()  => {});  // Media is paused
cjs.on('end',          ()  => {});  // Media ended
cjs.on('buffering',    ()  => {});  // Media is buffering / seeking
cjs.on('event',        (e) => {});  // Catch all events except 'error'
cjs.on('error',        (e) => {});  // Catch any errors

// Castjs functions
cjs.cast(source, [metadata]); // Create session with media
cjs.volume(0.7);              // Change volume
cjs.play();                   // Play media
cjs.pause();                  // Pause media
cjs.mute();                   // Mutes media
cjs.unmute();                 // Unmutes media
cjs.subtitle(2);              // Change active subtitle index
cjs.seek(15);                 // Seek 15 seconds
cjs.seek(15.9, true);         // Seek 15.9% percentage
cjs.disconnect();             // Disconnect session

// Castjs properties
cjs.version          // Castjs Version
cjs.receiver         // Receiver ID
cjs.available        // Casting is available
cjs.connected        // Connected with cast device
cjs.device           // Cast device name
cjs.src              // Media source
cjs.title            // Media title
cjs.description      // Media description
cjs.poster           // Media poster image
cjs.subtitles        // Media subtitles
cjs.volumeLevel      // Volume level
cjs.muted            // If muted
cjs.paused           // If paused
cjs.time             // Time in seconds
cjs.timePretty       // Time formatted in time hh:mm:ss
cjs.duration         // Duration in seconds
cjs.durationPretty   // Duration formatted in hh:mm:ss
cjs.progress         // Progress in percentage 0 - 100
cjs.state            // State of cast device
TODO
- Add local media and stream support after google fixes service worker crash
- Add name space messaging support for custom receivers
- Maybe add video element support: new Castjs($('#video'))

// Suggestions? Let me know!

Do you want to support my work, feel free to donate a ☕ Hot Beverage

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].