Showing
1 changed file
with
10 additions
and
0 deletions
| ... | ... | @@ -22,7 +22,17 @@ const emits = defineEmits<{ |
| 22 | 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 | 34 | function getStreamTypeByUrl(url = ''): StreamType | undefined { |
| 35 | + url = parsePlayUrl(url) || '' | |
| 26 | 36 | if (url.endsWith('.m3u8')) return 'hls' |
| 27 | 37 | else if (url.endsWith('.mp4')) return 'mp4' |
| 28 | 38 | else if (url.endsWith('.flv')) | ... | ... |