Commit f5368756a4e2e58346d7afa575a84e3894533151

Authored by ww
1 parent 67bcacea

perf: 优化手动输入流地址携带参数时无法获取视频协议类型

@@ -22,7 +22,17 @@ const emits = defineEmits<{ @@ -22,7 +22,17 @@ const emits = defineEmits<{
22 (eventName: 'onUnmounted', player: PresetPlayer): void 22 (eventName: 'onUnmounted', player: PresetPlayer): void
23 }>() 23 }>()
24 24
  25 +function parsePlayUrl(url: string) {
  26 + try {
  27 + return new URL(url).pathname
  28 + }
  29 + catch {
  30 + return url
  31 + }
  32 +}
  33 +
25 function getStreamTypeByUrl(url = ''): StreamType | undefined { 34 function getStreamTypeByUrl(url = ''): StreamType | undefined {
  35 + url = parsePlayUrl(url) || ''
26 if (url.endsWith('.m3u8')) return 'hls' 36 if (url.endsWith('.m3u8')) return 'hls'
27 else if (url.endsWith('.mp4')) return 'mp4' 37 else if (url.endsWith('.mp4')) return 'mp4'
28 else if (url.endsWith('.flv')) 38 else if (url.endsWith('.flv'))