Update: Experimenting with android tv / bubbleupnp to get stream working

live_tv_play
Juraj Nyíri 3 years ago
parent 7635cc351c
commit 8e42b969f5

@ -19407,16 +19407,9 @@ class PlayController {
case 'androidtv': case 'androidtv':
if (!lodash.isNil(data.epg)) { if (!lodash.isNil(data.epg)) {
const session = `${Math.floor(Date.now() / 1000)}`; const session = `${Math.floor(Date.now() / 1000)}`;
const streamData = await this.plex.tune(data.channelIdentifier, session); const streamLink = await this.plex.tune(data.channelIdentifier, session);
console.log(streamData); console.log(streamLink);
/* await this.playViaAndroidTV(entity.value, streamLink, instantPlay, provider);
await this.playViaAndroidTV(
entity.value,
streamData.MediaSubscription[0].MediaGrabOperation[0].Metadata.key,
instantPlay,
provider
);
*/
} }
else { else {
await this.playViaAndroidTV(entity.value, processData.guid, instantPlay, provider); await this.playViaAndroidTV(entity.value, processData.guid, instantPlay, provider);
@ -19430,7 +19423,7 @@ class PlayController {
const session = `PlexMeetsHomeAssistant-${Math.floor(Date.now() / 1000)}`; const session = `PlexMeetsHomeAssistant-${Math.floor(Date.now() / 1000)}`;
const streamURL = await this.plex.tune(data.channelIdentifier, session); const streamURL = await this.plex.tune(data.channelIdentifier, session);
console.log(`${this.plex.getBasicURL()}${streamURL}`); console.log(`${this.plex.getBasicURL()}${streamURL}`);
// this.playViaCast(entity.value, `${playlistLink}`); this.playViaCast(entity.value, `${streamURL}`);
} }
else if (this.hass.services.plex) { else if (this.hass.services.plex) {
const libraryName = lodash.isNil(processData.librarySectionTitle) const libraryName = lodash.isNil(processData.librarySectionTitle)
@ -19593,22 +19586,31 @@ class PlayController {
} }
}; };
this.playViaCast = (entityName, mediaLink) => { this.playViaCast = (entityName, mediaLink) => {
console.log({ mediaLink = this.plex.authorizeURL(`${this.plex.getBasicURL()}${mediaLink}`);
const payload = {
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
entity_id: entityName, entity_id: entityName,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_type: 'video', media_content_type: 'application/vnd.apple.mpegurl',
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_id: this.plex.authorizeURL(`${this.plex.getBasicURL()}${mediaLink}`) media_content_id: mediaLink
}); };
this.hass.callService('media_player', 'play_media', { /*
payload = {
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
entity_id: entityName, entity_id: entityName,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_type: 'video', media_content_type: 'cast',
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_id: this.plex.authorizeURL(`${this.plex.getBasicURL()}${mediaLink}`) media_content_id: `{
}); "app_name": "bubbleupnp",
"media_id": "${mediaLink}",
"media_type": "application/x-mpegURL"
}`
};
*/
console.log(payload);
this.hass.callService('media_player', 'play_media', payload);
}; };
this.playViaCastPlex = (entityName, contentType, mediaLink) => { this.playViaCastPlex = (entityName, contentType, mediaLink) => {
return this.hass.callService('media_player', 'play_media', { return this.hass.callService('media_player', 'play_media', {

@ -127,16 +127,10 @@ class PlayController {
case 'androidtv': case 'androidtv':
if (!_.isNil(data.epg)) { if (!_.isNil(data.epg)) {
const session = `${Math.floor(Date.now() / 1000)}`; const session = `${Math.floor(Date.now() / 1000)}`;
const streamData = await this.plex.tune(data.channelIdentifier, session); const streamLink = await this.plex.tune(data.channelIdentifier, session);
console.log(streamData); console.log(streamLink);
/*
await this.playViaAndroidTV( await this.playViaAndroidTV(entity.value, streamLink, instantPlay, provider);
entity.value,
streamData.MediaSubscription[0].MediaGrabOperation[0].Metadata.key,
instantPlay,
provider
);
*/
} else { } else {
await this.playViaAndroidTV(entity.value, processData.guid, instantPlay, provider); await this.playViaAndroidTV(entity.value, processData.guid, instantPlay, provider);
} }
@ -150,7 +144,7 @@ class PlayController {
const session = `PlexMeetsHomeAssistant-${Math.floor(Date.now() / 1000)}`; const session = `PlexMeetsHomeAssistant-${Math.floor(Date.now() / 1000)}`;
const streamURL = await this.plex.tune(data.channelIdentifier, session); const streamURL = await this.plex.tune(data.channelIdentifier, session);
console.log(`${this.plex.getBasicURL()}${streamURL}`); console.log(`${this.plex.getBasicURL()}${streamURL}`);
// this.playViaCast(entity.value, `${playlistLink}`); this.playViaCast(entity.value, `${streamURL}`);
} else if (this.hass.services.plex) { } else if (this.hass.services.plex) {
const libraryName = _.isNil(processData.librarySectionTitle) const libraryName = _.isNil(processData.librarySectionTitle)
? this.libraryName ? this.libraryName
@ -325,22 +319,33 @@ class PlayController {
}; };
private playViaCast = (entityName: string, mediaLink: string): void => { private playViaCast = (entityName: string, mediaLink: string): void => {
console.log({ mediaLink = this.plex.authorizeURL(`${this.plex.getBasicURL()}${mediaLink}`);
const payload: any = {
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
entity_id: entityName, entity_id: entityName,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_type: 'video', media_content_type: 'application/vnd.apple.mpegurl',
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_id: this.plex.authorizeURL(`${this.plex.getBasicURL()}${mediaLink}`) media_content_id: mediaLink
}); };
this.hass.callService('media_player', 'play_media', {
/*
payload = {
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
entity_id: entityName, entity_id: entityName,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_type: 'video', media_content_type: 'cast',
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
media_content_id: this.plex.authorizeURL(`${this.plex.getBasicURL()}${mediaLink}`) media_content_id: `{
}); "app_name": "bubbleupnp",
"media_id": "${mediaLink}",
"media_type": "application/x-mpegURL"
}`
};
*/
console.log(payload);
this.hass.callService('media_player', 'play_media', payload);
}; };
private playViaCastPlex = (entityName: string, contentType: string, mediaLink: string): Promise<void> => { private playViaCastPlex = (entityName: string, contentType: string, mediaLink: string): Promise<void> => {

Loading…
Cancel
Save