Created
April 29, 2020 02:36
-
-
Save hitode909/d5292edf5def11cd316314ce28d0c00b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><button id="masawada-cast-button" style="display: none">masawada castを開始する</button> | |
<div id="masawada-cast-button-not-supported" style="display: none">お使いのブラウザは<a href="https://developer.mozilla.org/en-US/docs/Web/API/Presentation_API" target="_blank">Presentation API</a>に対応していないようです</div> | |
</p> | |
<script> | |
(function () { | |
const button = document.querySelector('#masawada-cast-button'); | |
const error = document.querySelector('#masawada-cast-button-not-supported'); | |
const show = function () { | |
button.style.display = 'block'; | |
}; | |
const hide = function () { | |
error.style.display = 'block'; | |
}; | |
try { | |
const request = new PresentationRequest(['https://files.sushi.money/working-masawada.html']); | |
navigator.presentation.defaultRequest = request; | |
request.getAvailability().then(function (availability) { | |
if (!availability) { | |
hide(); | |
return; | |
} | |
show(); | |
button.addEventListener('click', function () { | |
request.start(); | |
}); | |
}).catch(function () { | |
hide(); | |
}); | |
} catch (error) { | |
hide(); | |
} | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment