Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Add AirPlay player button

Gabe Kangasd7229a8c6d51
diff --git a/webroot/index.html b/webroot/index.html
index fcb1faac51..a8a6f711a9 100644
--- a/webroot/index.html
+++ b/webroot/index.html
@@ -165,5 +165,7 @@ possible hacks
<script src="js/utils.js"></script>
<script src="js/message.js"></script>
<script src="js/app.js"></script>
+ <script src="js/player/airplay.js"></script>
+
</body>
</html>
\ No newline at end of file
diff --git a/webroot/js/player/airplay.js b/webroot/js/player/airplay.js
new file mode 100644
index 0000000000..ddec78981b
--- /dev/null
+++ b/webroot/js/player/airplay.js
@@ -0,0 +1,23 @@
+videojs.hookOnce('setup', function (player) {
+ if (window.WebKitPlaybackTargetAvailabilityEvent) {
+ var videoJsButtonClass = videojs.getComponent('Button');
+ var concreteButtonClass = videojs.extend(videoJsButtonClass, {
+
+ // The `init()` method will also work for constructor logic here, but it is
+ // deprecated. If you provide an `init()` method, it will override the
+ // `constructor()` method!
+ constructor: function () {
+ videoJsButtonClass.call(this, player);
+ }, // notice the comma
+
+ handleClick: function () {
+ const videoElement = document.getElementsByTagName('video')[0];
+ videoElement.webkitShowPlaybackTargetPicker();
+ }
+ });
+
+ var concreteButtonInstance = player.controlBar.addChild(new concreteButtonClass());
+ concreteButtonInstance.addClass("vjs-airplay");
+ }
+
+});
\ No newline at end of file
diff --git a/webroot/styles/layout.css b/webroot/styles/layout.css
index 61aa8d2428..cef96ce2f0 100644
--- a/webroot/styles/layout.css
+++ b/webroot/styles/layout.css
@@ -377,4 +377,8 @@ header h1 {
height: 40vh;
height: calc((var(--vh, 1vh) * 40));
min-height: 300px;
+}
+
+.vjs-airplay .vjs-icon-placeholder::before {
+ content: 'AP';
}
\ No newline at end of file