Permalink
Browse files

IT WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Loading branch information...
MarshallOfSound committed May 5, 2016
1 parent d4e51fc commit f81fbcdd3a865132ee328b76540c039312d96294
@@ -5,13 +5,13 @@ export default class Receiver {
this.capabilities = opt_capabilities || [chrome.cast.Capability.VIDEO_OUT, chrome.cast.Capability.AUDIO_OUT];
this.displayStatus = null;
this.friendlyName = friendlyName;
this.label = label;
this.label = 'rENwhtXTIxoASoh7UJVV7twdiEEo';
this.volume = opt_volume;

this.receiverType = chrome.cast.ReceiverType.CAST;

// DEV: Properties not in spec but in crx
this.ipAddress = null;
this.isActiveInput = null;
this.isActiveInput = true;
}
}
@@ -37,19 +37,23 @@ export default class Session {
this.app = app;
if (once) {
once = false;
this.transport = app.transportId;
this.transport = this.transportId = app.transportId;
this.clientId = `client-${Math.floor(Math.random() * 10e5)}`;
this.transportConnect = this.client.createChannel(this.clientId, this.transport, 'urn:x-cast:com.google.cast.tp.connection', 'JSON');
this.transportConnect.send({ type: 'CONNECT' });
transportHeartbeat = this.client.createChannel(this.clientId, this.transport, 'urn:x-cast:com.google.cast.tp.heartbeat', 'JSON');
this.status = chrome.cast.SessionStatus.CONNECTED;
this.sessionId = app.sessionId;
this.namespaces = app.namespaces;
this.displayName = app.displayName;
this.statusText = app.displayName;

// DEV: Media Listener
// TODO: Move somewhere nicer
this.addMessageListener('urn:x-cast:com.google.cast.media', (namespace, media) => {
console.info('Media Reciever', media);
const mediaObject = new chrome.cast.media.Media(this.app.sessionId, media.requestId);
this._mediaHooks.forEach((hookFn) => hookFn(mediaObject));
// const mediaObject = new chrome.cast.media.Media(this.app.sessionId, media.requestId);
// this._mediaHooks.forEach((hookFn) => hookFn(mediaObject));
});
_cb(this);
}
@@ -108,6 +112,7 @@ export default class Session {
addMessageListener(namespace, listener) {
this._createChannel(namespace);
this._channels[namespace].on('message', (data) => {
debugger;
listener(namespace, JSON.stringify(data));
});
console.info('Message Hook For: ', namespace);
@@ -124,7 +129,17 @@ export default class Session {
}

loadMedia(loadRequest, successCallback, errorCallback) {
console.info('loadMedia', loadRequest);
this.sendMediaMessage({
type: 'LOAD',
requestId: 0,
media: loadRequest.media,
activeTrackIds: loadRequest.activeTrackIds || [],
autoplay: loadRequest.autoplay || false,
currentTime: loadRequest.currentTime || 0,
customData: loadRequest.customData || {},
repeatMode: 'REPEAT_OFF',
});
successCallback();
// TODO: https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#loadMedia
}

@@ -149,6 +164,10 @@ export default class Session {
this._updateHooks = this._updateHooks.filter((item) => item !== listener);
}

sendMediaMessage(message) {
this.sendMessage('urn:x-cast:com.google.cast.media', message, () => {}, () => {});
}

// https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#sendMessage
sendMessage(namespace, message, successCallback, errorCallback) {
console.info('Sending Message', namespace, message);
@@ -199,7 +199,7 @@ export default class Cast {

static requestSessionById = (sessionId) => {
// TODO: https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.requestSessionById
console.log(sessionId);
console.log('Get Session', sessionId);
}

static setCustomReceivers = (receivers, successCallback, errorCallback) => {
@@ -2,7 +2,7 @@

export default class LoadRequest {
constructor(mediaInfo) {
console.info('mediaInfo', mediaInfo);
console.info('new LoadRequest', mediaInfo);
this.activeTrackIds = [];
this.autoplay = false;
this.currentTime = 0;
@@ -3,15 +3,15 @@
export default class Media {
constructor(sessionId, mediaSessionId) {
this.activeTrackIds = [];
this.currentItemId = null;
this.currentItemId = 1;
this.customData = {};
this.idleReason = null;
this.items = [];
this.loadingItemId = null;
this.media = null;
this.mediaSessionId = mediaSessionId;
this.playbackRate = 1;
this.playerState = chrome.cast.media.PlayerState.IDLE;
this.playerState = chrome.cast.media.PlayerState.PAUSED;
this.preloadedItemId = null;
this.repeatMode = chrome.cast.media.RepeatMode.OFF;
this.sessionId = sessionId;
@@ -25,7 +25,6 @@ export default class Media {
}

addUpdateListener(listener) {
console.warn('Add update listener');
// TODO: https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media#addUpdateListener
console.info('addUpdateListener', listener);
}
@@ -2,13 +2,13 @@

export default class MediaInfo {
constructor(contentId, contentType) {
console.info('MediaInfo', contentId, contentType);
console.info('new MediaInfo', contentId, contentType);
this.contentId = contentId;
this.contentType = contentType;
this.customData = {};
this.duration = null;
this.metadata = null;
this.streamType = null;
this.streamType = chrome.cast.media.StreamType.BUFFERED;
this.textTrackStyle = null;
this.tracks = [];
}
@@ -8,7 +8,7 @@ export default class MusicTrackMediaMetadata {
this.composer = null;
this.discNumber = null;
this.images = [];
this.metadataType = null;
this.metadataType = this.type = 3;
this.releaseDate = null;
this.songName = null;
this.title = null;

0 comments on commit f81fbcd

Please sign in to comment.