@@ -4,10 +4,11 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{type: string}>()
|
||||
const requireAssets = require.context('../assets', false, /\.svg$/)
|
||||
const SVGs = requireAssets.keys().reduce((svgs: {[propName:string]: string}, path: string) => {
|
||||
const svgFile = requireAssets(path)
|
||||
const svgModules = import.meta.glob('../assets/*.svg', { eager: true, import: 'default' }) as Record<string, string>
|
||||
|
||||
const SVGs = Object.entries(svgModules).reduce((svgs: {[propName:string]: string}, [path, svgFile]) => {
|
||||
const fileNameMatch = path.match(/^.*\/(.+?)\.svg$/)
|
||||
if (fileNameMatch) {
|
||||
svgs[fileNameMatch[1]] = svgFile
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
import MusicList from './components/aplayer-list.vue'
|
||||
import Controls from './components/aplayer-controller.vue'
|
||||
import Lyrics from './components/aplayer-lrc.vue'
|
||||
import Hls from 'hls.js'
|
||||
import { warn } from './utils'
|
||||
|
||||
// mutex playing instance
|
||||
@@ -667,20 +668,14 @@
|
||||
if (this.audio.canPlayType('application/x-mpegURL') || this.audio.canPlayType('application/vnd.apple.mpegURL')) {
|
||||
this.audio.src = src
|
||||
} else {
|
||||
try {
|
||||
const Hls = require('hls.js')
|
||||
if (Hls.isSupported()) {
|
||||
if (!this.hls) {
|
||||
this.hls = new Hls()
|
||||
}
|
||||
this.hls.loadSource(src)
|
||||
this.hls.attachMedia(this.audio)
|
||||
} else {
|
||||
warn('HLS is not supported on your browser')
|
||||
this.audio.src = src
|
||||
if (Hls.isSupported()) {
|
||||
if (!this.hls) {
|
||||
this.hls = new Hls()
|
||||
}
|
||||
} catch (e) {
|
||||
warn('hls.js is required to support m3u8')
|
||||
this.hls.loadSource(src)
|
||||
this.hls.attachMedia(this.audio)
|
||||
} else {
|
||||
warn('HLS is not supported on your browser')
|
||||
this.audio.src = src
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user