mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 08:46:35 +00:00
Add separate cast media entrypoint (with ES5) (#10527)
This commit is contained in:
parent
3fd0becfd4
commit
9425b943dd
@ -165,6 +165,7 @@ module.exports.config = {
|
|||||||
cast({ isProdBuild, latestBuild }) {
|
cast({ isProdBuild, latestBuild }) {
|
||||||
const entry = {
|
const entry = {
|
||||||
launcher: path.resolve(paths.cast_dir, "src/launcher/entrypoint.ts"),
|
launcher: path.resolve(paths.cast_dir, "src/launcher/entrypoint.ts"),
|
||||||
|
media: path.resolve(paths.cast_dir, "src/media/entrypoint.ts"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (latestBuild) {
|
if (latestBuild) {
|
||||||
|
@ -154,6 +154,15 @@ gulp.task("gen-index-cast-dev", (done) => {
|
|||||||
contentReceiver
|
contentReceiver
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const contentMedia = renderCastTemplate("media", {
|
||||||
|
latestMediaJS: "/frontend_latest/media.js",
|
||||||
|
es5MediaJS: "/frontend_es5/media.js",
|
||||||
|
});
|
||||||
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.cast_output_root, "media.html"),
|
||||||
|
contentMedia
|
||||||
|
);
|
||||||
|
|
||||||
const contentFAQ = renderCastTemplate("launcher-faq", {
|
const contentFAQ = renderCastTemplate("launcher-faq", {
|
||||||
latestLauncherJS: "/frontend_latest/launcher.js",
|
latestLauncherJS: "/frontend_latest/launcher.js",
|
||||||
es5LauncherJS: "/frontend_es5/launcher.js",
|
es5LauncherJS: "/frontend_es5/launcher.js",
|
||||||
@ -192,6 +201,15 @@ gulp.task("gen-index-cast-prod", (done) => {
|
|||||||
contentReceiver
|
contentReceiver
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const contentMedia = renderCastTemplate("media", {
|
||||||
|
latestMediaJS: latestManifest["media.js"],
|
||||||
|
es5MediaJS: es5Manifest["media.js"],
|
||||||
|
});
|
||||||
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.cast_output_root, "media.html"),
|
||||||
|
contentMedia
|
||||||
|
);
|
||||||
|
|
||||||
const contentFAQ = renderCastTemplate("launcher-faq", {
|
const contentFAQ = renderCastTemplate("launcher-faq", {
|
||||||
latestLauncherJS: latestManifest["launcher.js"],
|
latestLauncherJS: latestManifest["launcher.js"],
|
||||||
es5LauncherJS: es5Manifest["launcher.js"],
|
es5LauncherJS: es5Manifest["launcher.js"],
|
||||||
|
45
cast/src/html/media.html.template
Normal file
45
cast/src/html/media.html.template
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
--logo-image: url('https://www.home-assistant.io/images/home-assistant-logo.svg');
|
||||||
|
--logo-repeat: no-repeat;
|
||||||
|
--playback-logo-image: url('https://www.home-assistant.io/images/home-assistant-logo.svg');
|
||||||
|
--theme-hue: 200;
|
||||||
|
--progress-color: #03a9f4;
|
||||||
|
--splash-image: url('https://home-assistant.io/images/cast/splash.png');
|
||||||
|
--splash-size: cover;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
var _gaq=[['_setAccount','UA-57927901-10'],['_trackPageview']];
|
||||||
|
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||||||
|
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
||||||
|
s.parentNode.insertBefore(g,s)}(document,'script'));
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%= renderTemplate('_js_base') %>
|
||||||
|
|
||||||
|
<cast-media-player></cast-media-player>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import("<%= latestMediaJS %>");
|
||||||
|
window.latestJS = true;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
if (!window.latestJS) {
|
||||||
|
<% if (useRollup) { %>
|
||||||
|
_ls("/static/js/s.min.js").onload = function() {
|
||||||
|
System.import("<%= es5MediaJS %>");
|
||||||
|
};
|
||||||
|
<% } else { %>
|
||||||
|
_ls("<%= es5MediaJS %>");
|
||||||
|
<% } %>
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
25
cast/src/media/entrypoint.ts
Normal file
25
cast/src/media/entrypoint.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { CastReceiverContext } from "chromecast-caf-receiver/cast.framework";
|
||||||
|
|
||||||
|
const castContext =
|
||||||
|
cast.framework.CastContext.getInstance() as unknown as CastReceiverContext;
|
||||||
|
|
||||||
|
const playerManager = castContext.getPlayerManager();
|
||||||
|
|
||||||
|
playerManager.setMessageInterceptor(
|
||||||
|
cast.framework.messages.MessageType.LOAD,
|
||||||
|
(loadRequestData) => {
|
||||||
|
const media = loadRequestData.media;
|
||||||
|
// Special handling if it came from Google Assistant
|
||||||
|
if (media.entity) {
|
||||||
|
media.contentId = media.entity;
|
||||||
|
media.streamType = cast.framework.messages.StreamType.LIVE;
|
||||||
|
media.contentType = "application/vnd.apple.mpegurl";
|
||||||
|
// @ts-ignore
|
||||||
|
media.hlsVideoSegmentFormat =
|
||||||
|
cast.framework.messages.HlsVideoSegmentFormat.FMP4;
|
||||||
|
}
|
||||||
|
return loadRequestData;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
castContext.start();
|
Loading…
x
Reference in New Issue
Block a user