Remove Google Cast support since the JS library does not seem to be maintained anymore and it frequently breaks

This commit is contained in:
Pierre Rudloff 2017-07-03 10:17:37 +02:00
parent b5ef14a930
commit dd00e9d279
9 changed files with 3 additions and 128 deletions

View file

@ -11,7 +11,7 @@ module.exports = function (grunt) {
uglify: { uglify: {
combine: { combine: {
files: { files: {
'dist/main.js': ['js/cast.js'] 'dist/main.js': ['js/*.js']
} }
} }
}, },
@ -128,8 +128,8 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-potomo'); grunt.loadNpmTasks('grunt-potomo');
grunt.loadNpmTasks('grunt-contrib-csslint'); grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.registerTask('default', ['uglify', 'cssmin', 'potomo']); grunt.registerTask('default', ['cssmin', 'potomo']);
grunt.registerTask('lint', ['jslint', 'csslint', 'fixpack', 'jsonlint', 'phpcs']); grunt.registerTask('lint', ['csslint', 'fixpack', 'jsonlint', 'phpcs']);
grunt.registerTask('test', ['phpunit']); grunt.registerTask('test', ['phpunit']);
grunt.registerTask('doc', ['phpdocumentor']); grunt.registerTask('doc', ['phpdocumentor']);
grunt.registerTask('release', ['default', 'githash', 'compress']); grunt.registerTask('release', ['default', 'githash', 'compress']);

View file

@ -544,18 +544,6 @@ h1 {
max-width:700px; max-width:700px;
} }
.cast_btn {
cursor:pointer;
}
.cast_hidden {
display:none;
}
.cast_icon {
vertical-align:middle;
}
.format { .format {
text-align:left; text-align:left;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

View file

@ -1,109 +0,0 @@
/*global chrome*/
/*jslint browser: true, nomen: true */
var castModule = (function () {
'use strict';
var launchBtn, disabledBtn, stopBtn, session;
function receiverListener(e) {
return (e === chrome.cast.ReceiverAvailability.AVAILABLE);
}
function onMediaDiscovered() {
if (launchBtn) {
stopBtn.classList.remove('cast_hidden');
launchBtn.classList.add('cast_hidden');
}
}
function onStopCast() {
stopBtn.classList.add('cast_hidden');
launchBtn.classList.remove('cast_hidden');
}
function onStopCastError(e) {
onStopCast();
throw e.description;
}
function updateListener() {
if (session.status !== chrome.cast.SessionStatus.CONNECTED) {
onStopCast();
}
}
function sessionListener(e) {
session = e;
session.addMediaListener(onMediaDiscovered);
session.addUpdateListener(updateListener);
if (session.media.length !== 0) {
onMediaDiscovered();
}
}
function stopCast() {
session.stop(onStopCast, onStopCastError);
}
function onMediaError(e) {
stopCast();
throw e.description;
}
function onRequestSessionSuccess(e) {
session = e;
var videoLink = document.getElementById('video_link'), videoURL = videoLink.dataset.video, mediaInfo = new chrome.cast.media.MediaInfo(videoURL, 'video/' + videoLink.dataset.ext), request = new chrome.cast.media.LoadRequest(mediaInfo);
session.loadMedia(request, onMediaDiscovered, onMediaError);
}
function onLaunchError(e) {
throw e.description;
}
function launchCast() {
chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError);
}
function onInitSuccess() {
launchBtn = document.getElementById('cast_btn_launch');
disabledBtn = document.getElementById('cast_disabled');
stopBtn = document.getElementById('cast_btn_stop');
if (launchBtn) {
disabledBtn.classList.add('cast_hidden');
launchBtn.classList.remove('cast_hidden');
launchBtn.addEventListener('click', launchCast, false);
stopBtn.addEventListener('click', stopCast, false);
}
}
function onError(e) {
throw e.code;
}
function initializeCastApi() {
var sessionRequest = new chrome.cast.SessionRequest(chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID),
apiConfig = new chrome.cast.ApiConfig(sessionRequest, sessionListener, receiverListener, chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED);
chrome.cast.initialize(apiConfig, onInitSuccess, onError);
}
function loadCastApi(loaded, errorInfo) {
if (loaded) {
initializeCastApi();
} else {
throw errorInfo;
}
}
return {
init: function () {
var intro = document.getElementById('download_intro');
if (intro) {
intro.insertAdjacentHTML('beforeend', '<img class="cast_icon" id="cast_disabled" src="img/ic_media_route_disabled_holo_light.png" alt="" title="Google Cast is not supported on this browser." /> <img class="cast_btn cast_hidden cast_icon" id="cast_btn_launch" src="img/ic_media_route_off_holo_light.png" title="Cast to ChromeCast" alt="Google Cast™" /> <img src="img/ic_media_route_on_holo_light.png" alt="Casting to ChromeCast…" title="Stop casting" id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" />');
window.__onGCastApiAvailable = loadCastApi;
}
}
};
}());
if (typeof window === 'object') {
window.addEventListener('load', castModule.init, false);
}

View file

@ -16,6 +16,5 @@
{t}Based on{/t} <a href="http://rg3.github.io/youtube-dl/">youtube-dl</a> {t}Based on{/t} <a href="http://rg3.github.io/youtube-dl/">youtube-dl</a>
</div> </div>
</footer> </footer>
<script src="{base_url}/dist/main.js"></script>
</body> </body>
</html> </html>

View file

@ -19,7 +19,6 @@
<meta name="twitter:title" content="AllTube Download{if isset($title)} - {$title|escape}{/if}" /> <meta name="twitter:title" content="AllTube Download{if isset($title)} - {$title|escape}{/if}" />
<meta name="twitter:image" content="{base_url}/img/logo.png" /> <meta name="twitter:image" content="{base_url}/img/logo.png" />
<meta name="twitter:creator" content="@Tael67" /> <meta name="twitter:creator" content="@Tael67" />
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<meta name="theme-color" content="#4F4F4F"> <meta name="theme-color" content="#4F4F4F">
<link rel="manifest" href="{base_url}/resources/manifest.json" /> <link rel="manifest" href="{base_url}/resources/manifest.json" />
</head> </head>

View file

@ -5,8 +5,6 @@
{include file="inc/logo.tpl"} {include file="inc/logo.tpl"}
<p id="download_intro">{t}You are going to download{/t}<i itemprop="name"> <p id="download_intro">{t}You are going to download{/t}<i itemprop="name">
<a itemprop="url" id="video_link" <a itemprop="url" id="video_link"
data-ext="{$video->ext}"
data-video="{$video->url|escape}"
href="{$video->webpage_url}"> href="{$video->webpage_url}">
{$video->title}</a></i>. {$video->title}</a></i>.
</p> </p>