Add ability to listen to audio only formats for videos
This commit is contained in:
parent
029c492cf8
commit
138f4b90f4
|
@ -41,6 +41,10 @@ export default Vue.extend({
|
||||||
storyboardSrc: {
|
storyboardSrc: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
thumbnail: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
|
@ -113,10 +117,14 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedDefaultQuality: function () {
|
selectedDefaultQuality: function () {
|
||||||
let selectedQuality = null
|
let selectedQuality = ''
|
||||||
|
|
||||||
if (this.sourceList.length === 0) {
|
if (this.sourceList.length === 0) {
|
||||||
return this.defaultQuality
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof (this.sourceList[0].qualityLabel) === 'number') {
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxAvailableQuality = parseInt(this.sourceList[this.sourceList.length - 1].qualityLabel.replace(/p|k/, ''))
|
const maxAvailableQuality = parseInt(this.sourceList[this.sourceList.length - 1].qualityLabel.replace(/p|k/, ''))
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<video
|
<video
|
||||||
:id="id"
|
:id="id"
|
||||||
class="ftVideoPlayer video-js vjs-default-skin"
|
class="ftVideoPlayer video-js vjs-default-skin"
|
||||||
|
:poster="thumbnail"
|
||||||
controls
|
controls
|
||||||
preload="auto"
|
preload="auto"
|
||||||
:data-setup="JSON.stringify(dataSetup)"
|
:data-setup="JSON.stringify(dataSetup)"
|
||||||
|
|
|
@ -21,12 +21,12 @@ export default Vue.extend({
|
||||||
formatNames: [
|
formatNames: [
|
||||||
'Dash Formats',
|
'Dash Formats',
|
||||||
'Legacy Formats',
|
'Legacy Formats',
|
||||||
'YouTube Player'
|
'Audio Formats'
|
||||||
],
|
],
|
||||||
formatValues: [
|
formatValues: [
|
||||||
'dash',
|
'dash',
|
||||||
'legacy',
|
'legacy',
|
||||||
'youtube'
|
'audio'
|
||||||
],
|
],
|
||||||
qualityNames: [
|
qualityNames: [
|
||||||
'Auto',
|
'Auto',
|
||||||
|
|
|
@ -56,12 +56,13 @@ export default Vue.extend({
|
||||||
formatTypeLabel: 'VIDEO FORMATS',
|
formatTypeLabel: 'VIDEO FORMATS',
|
||||||
formatTypeNames: [
|
formatTypeNames: [
|
||||||
'USE DASH FORMATS',
|
'USE DASH FORMATS',
|
||||||
'USE LEGACY FORMATS'
|
'USE LEGACY FORMATS',
|
||||||
|
'USE AUDIO FORMATS'
|
||||||
],
|
],
|
||||||
formatTypeValues: [
|
formatTypeValues: [
|
||||||
'dash',
|
'dash',
|
||||||
'legacy',
|
'legacy',
|
||||||
'youtube'
|
'audio'
|
||||||
],
|
],
|
||||||
shareLabel: 'SHARE VIDEO',
|
shareLabel: 'SHARE VIDEO',
|
||||||
shareNames: [
|
shareNames: [
|
||||||
|
@ -132,6 +133,9 @@ export default Vue.extend({
|
||||||
case 'legacy':
|
case 'legacy':
|
||||||
this.$parent.enableLegacyFormat()
|
this.$parent.enableLegacyFormat()
|
||||||
break
|
break
|
||||||
|
case 'audio':
|
||||||
|
this.$parent.enableAudioFormat()
|
||||||
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,9 @@ export default Vue.extend({
|
||||||
videoPublished: 0,
|
videoPublished: 0,
|
||||||
videoStoryboardSrc: '',
|
videoStoryboardSrc: '',
|
||||||
audioUrl: '',
|
audioUrl: '',
|
||||||
|
activeSourceList: [],
|
||||||
videoSourceList: [],
|
videoSourceList: [],
|
||||||
|
audioSourceList: [],
|
||||||
captionSourceList: [],
|
captionSourceList: [],
|
||||||
recommendedVideos: [],
|
recommendedVideos: [],
|
||||||
watchingPlaylist: false,
|
watchingPlaylist: false,
|
||||||
|
@ -91,6 +93,23 @@ export default Vue.extend({
|
||||||
return this.$store.getters.getForceLocalBackendForLegacy
|
return this.$store.getters.getForceLocalBackendForLegacy
|
||||||
},
|
},
|
||||||
|
|
||||||
|
thumbnailPreference: function () {
|
||||||
|
return this.$store.getters.getThumbnailPreference
|
||||||
|
},
|
||||||
|
|
||||||
|
thumbnail: function () {
|
||||||
|
switch (this.thumbnailPreference) {
|
||||||
|
case 'start':
|
||||||
|
return `https://i.ytimg.com/vi/${this.videoId}/mq1.jpg`
|
||||||
|
case 'middle':
|
||||||
|
return `https://i.ytimg.com/vi/${this.videoId}/mq2.jpg`
|
||||||
|
case 'end':
|
||||||
|
return `https://i.ytimg.com/vi/${this.videoId}/mq3.jpg`
|
||||||
|
default:
|
||||||
|
return `https://i.ytimg.com/vi/${this.videoId}/mqdefault.jpg`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
youtubeNoCookieEmbeddedFrame: function () {
|
youtubeNoCookieEmbeddedFrame: function () {
|
||||||
return `<iframe width='560' height='315' src='https://www.youtube-nocookie.com/embed/${this.videoId}?rel=0' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>`
|
return `<iframe width='560' height='315' src='https://www.youtube-nocookie.com/embed/${this.videoId}?rel=0' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>`
|
||||||
},
|
},
|
||||||
|
@ -205,6 +224,25 @@ export default Vue.extend({
|
||||||
}).reverse()
|
}).reverse()
|
||||||
} else {
|
} else {
|
||||||
this.videoSourceList = result.player_response.streamingData.formats
|
this.videoSourceList = result.player_response.streamingData.formats
|
||||||
|
|
||||||
|
this.audioSourceList = result.player_response.streamingData.adaptiveFormats.filter((format) => {
|
||||||
|
return format.mimeType.includes('audio')
|
||||||
|
}).map((format) => {
|
||||||
|
return {
|
||||||
|
url: format.url,
|
||||||
|
type: format.mimeType,
|
||||||
|
label: 'Audio',
|
||||||
|
qualityLabel: format.bitrate
|
||||||
|
}
|
||||||
|
}).sort((a, b) => {
|
||||||
|
return a.qualityLabel - b.qualityLabel
|
||||||
|
})
|
||||||
|
|
||||||
|
if (this.activeFormat === 'audio') {
|
||||||
|
this.activeSourceList = this.audioSourceList
|
||||||
|
} else {
|
||||||
|
this.activeSourceList = this.videoSourceList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The response provides a storyboard, however it returns a 403 error.
|
// The response provides a storyboard, however it returns a 403 error.
|
||||||
|
@ -319,6 +357,25 @@ export default Vue.extend({
|
||||||
this.getLegacyFormats()
|
this.getLegacyFormats()
|
||||||
} else {
|
} else {
|
||||||
this.videoSourceList = result.formatStreams.reverse()
|
this.videoSourceList = result.formatStreams.reverse()
|
||||||
|
|
||||||
|
this.audioSourceList = result.adaptiveFormats.filter((format) => {
|
||||||
|
return format.type.includes('audio')
|
||||||
|
}).map((format) => {
|
||||||
|
return {
|
||||||
|
url: format.url,
|
||||||
|
type: format.type,
|
||||||
|
label: 'Audio',
|
||||||
|
qualityLabel: parseInt(format.bitrate)
|
||||||
|
}
|
||||||
|
}).sort((a, b) => {
|
||||||
|
return a.qualityLabel - b.qualityLabel
|
||||||
|
})
|
||||||
|
|
||||||
|
if (this.activeFormat === 'audio') {
|
||||||
|
this.activeSourceList = this.audioSourceList
|
||||||
|
} else {
|
||||||
|
this.activeSourceList = this.videoSourceList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
|
@ -378,6 +435,21 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activeFormat = 'legacy'
|
this.activeFormat = 'legacy'
|
||||||
|
this.activeSourceList = this.videoSourceList
|
||||||
|
this.hidePlayer = true
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.hidePlayer = false
|
||||||
|
}, 100)
|
||||||
|
},
|
||||||
|
|
||||||
|
enableAudioFormat: function () {
|
||||||
|
if (this.activeFormat === 'audio') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activeFormat = 'audio'
|
||||||
|
this.activeSourceList = this.audioSourceList
|
||||||
this.hidePlayer = true
|
this.hidePlayer = true
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -7,10 +7,11 @@
|
||||||
<ft-video-player
|
<ft-video-player
|
||||||
v-if="!isLoading && !hidePlayer"
|
v-if="!isLoading && !hidePlayer"
|
||||||
:dash-src="dashSrc"
|
:dash-src="dashSrc"
|
||||||
:source-list="videoSourceList"
|
:source-list="activeSourceList"
|
||||||
:caption-list="captionSourceList"
|
:caption-list="captionSourceList"
|
||||||
:storyboard-src="videoStoryboardSrc"
|
:storyboard-src="videoStoryboardSrc"
|
||||||
:format="activeFormat"
|
:format="activeFormat"
|
||||||
|
:thumbnail="thumbnail"
|
||||||
class="videoPlayer"
|
class="videoPlayer"
|
||||||
:class="{ theatrePlayer: useTheatreMode }"
|
:class="{ theatrePlayer: useTheatreMode }"
|
||||||
ref="videoPlayer"
|
ref="videoPlayer"
|
||||||
|
|
Loading…
Reference in New Issue