Only show CC icon for video (#412)
This commit is contained in:
@@ -30,8 +30,7 @@ function renderMedia (state) {
|
|||||||
|
|
||||||
// Unfortunately, play/pause can't be done just by modifying HTML.
|
// Unfortunately, play/pause can't be done just by modifying HTML.
|
||||||
// Instead, grab the DOM node and play/pause it if necessary
|
// Instead, grab the DOM node and play/pause it if necessary
|
||||||
var mediaType = state.playing.type /* 'audio' or 'video' */
|
var mediaElement = document.querySelector(state.playing.type) /* get the <video> or <audio> tag */
|
||||||
var mediaElement = document.querySelector(mediaType) /* get the <video> or <audio> tag */
|
|
||||||
if (mediaElement !== null) {
|
if (mediaElement !== null) {
|
||||||
if (state.playing.isPaused && !mediaElement.paused) {
|
if (state.playing.isPaused && !mediaElement.paused) {
|
||||||
mediaElement.pause()
|
mediaElement.pause()
|
||||||
@@ -85,7 +84,7 @@ function renderMedia (state) {
|
|||||||
${trackTags}
|
${trackTags}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
mediaTag.tagName = mediaType // conditional tag name
|
mediaTag.tagName = state.playing.type // conditional tag name
|
||||||
|
|
||||||
// Show the media.
|
// Show the media.
|
||||||
return hx`
|
return hx`
|
||||||
@@ -99,7 +98,7 @@ function renderMedia (state) {
|
|||||||
|
|
||||||
// As soon as the video loads enough to know the video dimensions, resize the window
|
// As soon as the video loads enough to know the video dimensions, resize the window
|
||||||
function onLoadedMetadata (e) {
|
function onLoadedMetadata (e) {
|
||||||
if (mediaType !== 'video') return
|
if (state.playing.type !== 'video') return
|
||||||
var video = e.target
|
var video = e.target
|
||||||
var dimensions = {
|
var dimensions = {
|
||||||
width: video.videoWidth,
|
width: video.videoWidth,
|
||||||
@@ -253,14 +252,16 @@ function renderPlayerControls (state) {
|
|||||||
`
|
`
|
||||||
]
|
]
|
||||||
|
|
||||||
// show closed captions icon
|
if (state.playing.type === 'video') {
|
||||||
elements.push(hx`
|
// show closed captions icon
|
||||||
<i.icon.closed-captions
|
elements.push(hx`
|
||||||
class=${state.playing.subtitles.enabled ? 'active' : 'disabled'}
|
<i.icon.closed-captions
|
||||||
onclick=${handleSubtitles}>
|
class=${state.playing.subtitles.enabled ? 'active' : 'disabled'}
|
||||||
closed_captions
|
onclick=${handleSubtitles}>
|
||||||
</i>
|
closed_captions
|
||||||
`)
|
</i>
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
// If we've detected a Chromecast or AppleTV, the user can play video there
|
// If we've detected a Chromecast or AppleTV, the user can play video there
|
||||||
var isOnChromecast = state.playing.location.startsWith('chromecast')
|
var isOnChromecast = state.playing.location.startsWith('chromecast')
|
||||||
|
|||||||
Reference in New Issue
Block a user