feat: react-alipalyer对接

This commit is contained in:
mozzie 2023-02-27 18:01:37 +08:00
parent a5dc0e4531
commit cdd17b3bd6
5 changed files with 106 additions and 3 deletions

View File

@ -0,0 +1,26 @@
.bs-card {
.arco-card-body {
padding: 10px;
}
.mask {
height: 164px;
background-color: rgba(0, 0, 0, 0.3);
overflow: hidden;
.cover {
height: 100%;
background-size: cover;
}
}
.bottom-des {
display: flex;
justify-content: space-between;
span {
flex: 1;
color: var(--color-text-3);
}
a {
cursor: pointer;
color: rgb(var(--primary-6));
}
}
}

View File

@ -0,0 +1,36 @@
import { Card } from "@arco-design/web-react";
import { url } from "inspector";
import "./index.less";
const { Meta } = Card;
function BsCard() {
return (
<Card
className="bs-card"
hoverable
style={{ width: 360 }}
cover={
<div className="mask">
<div
className="cover"
style={{
backgroundImage:
"url('//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp')",
}}
></div>
</div>
}
>
<Meta
description={
<div className="bottom-des">
<span>card description</span>
<a>Go</a>
</div>
}
/>
</Card>
);
}
export default BsCard;

View File

@ -2,7 +2,7 @@ header {
position: fixed; position: fixed;
left: 0; left: 0;
right: 0; right: 0;
z-index: 1994; z-index: 19;
height: 60px; height: 60px;
background: #24292f; background: #24292f;
color: #d7d7d7; color: #d7d7d7;

View File

@ -1,12 +1,23 @@
import { useRef } from "react";
import { useLink, useMount, useScript } from "../../hook"; import { useLink, useMount, useScript } from "../../hook";
import "./index.less"; import "./index.less";
interface IVideo {
fileID: string;
appID: string;
psign?: string;
}
/** /**
* demo页面https://tcplayer.vcube.tencent.com/
*
* Chrome Firefox H5 Webrtc , tcplayer.vx.x.x.min.js TXLivePlayer-x.x.x.min.js * Chrome Firefox H5 Webrtc , tcplayer.vx.x.x.min.js TXLivePlayer-x.x.x.min.js
* Webrtc Webrtc HLS hls.min.x.xx.xm.js * Webrtc Webrtc HLS hls.min.x.xx.xm.js
* <video objectFill /> fill填满变形cover等比例会裁剪, contain等比例有黑边 * <video objectFill /> fill填满变形cover等比例会裁剪, contain等比例有黑边
*/ */
function Player() { function Player() {
const playerRef = useRef<any>();
useLink(["/player/tcplayer_pure.min.css"]); useLink(["/player/tcplayer_pure.min.css"]);
useScript( useScript(
["/player/libs/hls.min.0.13.2m.js", "/player/tcplayer.v4.7.2.min.js"], ["/player/libs/hls.min.0.13.2m.js", "/player/tcplayer.v4.7.2.min.js"],
@ -28,7 +39,7 @@ function Player() {
); );
return el; return el;
}; };
const player = TCPlayer("player", { playerRef.current = TCPlayer("player", {
fileID: "243791579995468466", fileID: "243791579995468466",
appID: "1500018521", appID: "1500018521",
//私有加密播放需填写 psign psign 即播放器签名签名介绍和生成方式参见链接https://cloud.tencent.com/document/product/266/42436 //私有加密播放需填写 psign psign 即播放器签名签名介绍和生成方式参见链接https://cloud.tencent.com/document/product/266/42436
@ -37,6 +48,13 @@ function Player() {
} }
); );
/**
*
*/
const changeVideo = (video: IVideo) => {
playerRef.current!.loadVideoByID({ ...video });
};
return ( return (
<div className="player-container"> <div className="player-container">
<video <video

View File

@ -1,13 +1,36 @@
import "./index.less"; import "./index.less";
import Player from "../../components/Player"; import Player from "../../components/Player";
import { useMount } from "../../hook"; import { useMount } from "../../hook";
import { Select, Message } from "@arco-design/web-react";
const Option = Select.Option;
const options = ["全部", "最新的"];
import BsCard from "../../components/Card";
export default function Index() { export default function Index() {
useMount(() => {}); useMount(() => {});
return ( return (
<div className="container course"> <div className="container course">
<Player /> <div>
<BsCard />
</div>
<Select
placeholder="排序规则"
bordered={false}
style={{ width: 154 }}
onChange={(value) =>
Message.info({
content: `You select ${value}.`,
showIcon: true,
})
}
>
{options.map((option, index) => (
<Option key={option} disabled={index === 3} value={option}>
{option}
</Option>
))}
</Select>
</div> </div>
); );
} }