|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
|
|
|
|
import { Button, Slider, Select, Space, Card } from 'antd';
|
|
|
|
|
import { PauseCircleOutlined, PlayCircleOutlined, ExpandOutlined } from '@ant-design/icons';
|
|
|
|
|
import 'aliyun-aliplayer/build/skins/default/aliplayer-min.css';
|
|
|
|
|
|
|
|
|
|
interface AliPlayerProps {
|
|
|
|
|
vid: string;
|
|
|
|
@ -25,8 +24,11 @@ const AliPlayer: React.FC<AliPlayerProps> = ({
|
|
|
|
|
|
|
|
|
|
// 初始化播放器
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const link = document.createElement('link');
|
|
|
|
|
const script = document.createElement('script');
|
|
|
|
|
script.src = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.25.1/aliplayer-min.js';
|
|
|
|
|
link.rel = "stylesheet"
|
|
|
|
|
link.href = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.29.1/skins/default/aliplayer-min.css'
|
|
|
|
|
script.src = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.29.1/aliplayer-min.js';
|
|
|
|
|
script.onload = () => {
|
|
|
|
|
if (containerRef.current) {
|
|
|
|
|
playerRef.current = new (window as any).Aliplayer({
|
|
|
|
@ -51,12 +53,14 @@ const AliPlayer: React.FC<AliPlayerProps> = ({
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
document.head.appendChild(link);
|
|
|
|
|
document.head.appendChild(script);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
if (playerRef.current) {
|
|
|
|
|
playerRef.current.dispose();
|
|
|
|
|
}
|
|
|
|
|
document.head.removeChild(link);
|
|
|
|
|
document.head.removeChild(script);
|
|
|
|
|
};
|
|
|
|
|
}, [vid, playAuth]);
|
|
|
|
|