优化Video和Map
parent
0b443c8a52
commit
c80dde1826
|
|
@ -34,11 +34,8 @@ const MapSelector = (props) => {
|
||||||
|
|
||||||
// 初始化地图
|
// 初始化地图
|
||||||
const initMap = async () => {
|
const initMap = async () => {
|
||||||
await dynamicLoadJs("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr");
|
|
||||||
|
|
||||||
if (!window.BMapGL) {
|
if (!window.BMapGL) {
|
||||||
console.error("BMapGL is not loaded");
|
await dynamicLoadJs("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,11 @@ const AliPlayer = forwardRef(({
|
||||||
const onCreateAliPlayer = async () => {
|
const onCreateAliPlayer = async () => {
|
||||||
if (!containerRef.current)
|
if (!containerRef.current)
|
||||||
return;
|
return;
|
||||||
await dynamicLoadJs("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/aliplayer-min.js");
|
if (!window.Aliplayer) {
|
||||||
await dynamicLoadCss("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/skins/default/aliplayer-min.css");
|
await dynamicLoadJs("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/aliplayer-min.js");
|
||||||
|
await dynamicLoadCss("https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/skins/default/aliplayer-min.css");
|
||||||
|
}
|
||||||
|
|
||||||
onDisposeAliPlayer();
|
onDisposeAliPlayer();
|
||||||
|
|
||||||
const skinLayout = [
|
const skinLayout = [
|
||||||
|
|
@ -79,51 +82,49 @@ const AliPlayer = forwardRef(({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window.Aliplayer !== "undefined") {
|
playerRef.current = new window.Aliplayer(
|
||||||
playerRef.current = new window.Aliplayer(
|
{
|
||||||
{
|
id: className,
|
||||||
id: className,
|
...(source
|
||||||
...(source
|
? { source }
|
||||||
? { source }
|
: {
|
||||||
: {
|
vid,
|
||||||
vid,
|
playauth: playAuth,
|
||||||
playauth: playAuth,
|
qualitySort: "asc",
|
||||||
qualitySort: "asc",
|
format: "m3u8",
|
||||||
format: "m3u8",
|
encryptType: 1,
|
||||||
encryptType: 1,
|
mediaType: "video",
|
||||||
mediaType: "video",
|
isLive: true,
|
||||||
isLive: true,
|
rePlay: false,
|
||||||
rePlay: false,
|
playsinline: true,
|
||||||
playsinline: true,
|
controlBarVisibility: "hover",
|
||||||
controlBarVisibility: "hover",
|
}),
|
||||||
}),
|
cover,
|
||||||
cover,
|
width,
|
||||||
width,
|
height,
|
||||||
height,
|
autoplay,
|
||||||
autoplay,
|
isLive,
|
||||||
isLive,
|
useH5Prism: true,
|
||||||
useH5Prism: true,
|
skinLayout,
|
||||||
skinLayout,
|
},
|
||||||
},
|
(player) => {
|
||||||
(player) => {
|
if (autoplay) {
|
||||||
if (autoplay) {
|
player.play();
|
||||||
player.play();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.on("ended", () => {
|
player.on("ended", () => {
|
||||||
onEnded && onEnded();
|
onEnded && onEnded();
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on("timeupdate", () => {
|
player.on("timeupdate", () => {
|
||||||
onTimeupdate && onTimeupdate(player.getCurrentTime());
|
onTimeupdate && onTimeupdate(player.getCurrentTime());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (playTime > 0) {
|
if (playTime > 0) {
|
||||||
player.seek(playTime);
|
player.seek(playTime);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue