1.3.6-alpha.11 • Published 22 hours ago

@gaopeng123/rc-multi-player v1.3.6-alpha.11

Weekly downloads
-
License
MIT
Repository
github
Last release
22 hours ago

播放器组件

基础属性

属性说明类型默认值
objectFit视频填充'fill' | 'contain ' | 'cover' | 'scale-down' | 'none ' | 'initial ' | 'inherit'fill
mediaDataSource视频属性
robustness容错配置{ // 播放过程中缓冲器最小矫正的时间 默认为1000ms bufferTime: DOMHighResTimeStamp; // 多场时间探测一次 默认5000ms loopBufferTime: DOMHighResTimeStamp; // 最大断线重连次数 默认为 5 次 maxResetTimes: number; };
extraParams额外的参数配置{}any
events事件订阅{ // 视频播放开始 onLoadStart?: (playerConfig?: PlayerConfig) => void; // 点击视频重新加载 onReload?: (playerConfig?: PlayerConfig) => void; // 加载错误 onLoadError?: (playerConfig?: PlayerConfig) => void; // 流加载结束 onLoadEnd?: (playerConfig?: PlayerConfig)=> void; // 最大重试次数 onMaxReload?: (playerConfig?: PlayerConfig) => void; // 视频结束 onClose?: (playerConfig?: PlayerConfig) => void; }// 回放视频变更事件 onTimeChange?: (playerConfig?: PlayerConfig) => void; }
width视频宽度string |number100%
height视频高度string |number100%

RcFlvPlayer

flv播放器,依赖@gaopeng123/multi-player

在线demo

Usage

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {RcMultiPlayer} from "../src";
import {useEffect, useState} from "react";

const App = () => {
    const [mediaDataSource, setMediaDataSource] = useState<any>({});

    useEffect(() => {
        setTimeout(() => {
            setMediaDataSource({url: 'https://xxx/flv/xxx'})
        }, 2000);
    }, [])
    return (
        <RcMultiPlayer
            mediaDataSource={mediaDataSource}
        />
    );
};

ReactDOM.render(<App/>, document.getElementById('root'));

RcWebRTCPlayer

WebRTC 播放器在线demo

Usage

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {RcWebRTCPlayer} from "../src";
import {useEffect, useState} from "react";

const App = () => {
    const [mediaDataSource, setMediaDataSource] = useState<any>({});

    useEffect(() => {
        setTimeout(() => {
            setMediaDataSource({url: 'https://xxx/flv/xxx'})
        }, 2000);
    }, [])
    return (
        <RcWebRTCPlayer
            mediaDataSource={mediaDataSource}
        />
    );
};

ReactDOM.render(<App/>, document.getElementById('root'));

RcMultiPlayer

混合播放器,双协议在线demo

属性说明类型默认值
protocol协议类型'FLV' | 'WebRTC'FLV
title视频左上角展示内容string | ReactNodenull
className样式
maxPlayerTime最大播放时长,超出后自动关闭"3min" | '5min' | 'forever'forever

Usage

import React from 'react';
import MultiPlayer from "./MultiPlayer";
import styles from '../styles.module.less';
import { LayoutPlayerProps, PlayerConfig, } from "./PlayerTyping";
import { MultiStoreEnum } from "../MultiTyping";

const LayoutPlayer: React.FC<LayoutPlayerProps> = (props) => {
    const { layoutIndex, playerConfig, selected, mediaDataSource, dispatch, events, state } = props;
    const onClose = () => {
        dispatch({
            index: layoutIndex,
            value: null
        })
    }

    const playerEvents = Object.assign({}, events, {
        onClose: (playerConfig: PlayerConfig) => {
            onClose();
            if (events?.onClose) {
                events?.onClose(Object.assign({}, playerConfig, { layoutIndex }));
            }
        },
        onReload: (playerConfig: PlayerConfig) => {
            if (events?.onReload) {
                events?.onReload(Object.assign({}, playerConfig, { layoutIndex }));
            }
        },
        onMaxReload: (playerConfig: PlayerConfig) => {
            if (events?.onMaxReload) {
                events?.onMaxReload(Object.assign({}, playerConfig, { layoutIndex }));
            }
        }
    });

    const screenConfig = state[MultiStoreEnum.screenConfig];

    const { maxPlayerTime } = screenConfig;

    return (
        <MultiPlayer
            maxPlayerTime={maxPlayerTime}
            events={playerEvents}
            mediaDataSource={mediaDataSource}
            protocol={playerConfig?.protocol}
            extraParams={playerConfig?.extraParams}
            title={playerConfig?.title}
            className={selected ? styles.selected : styles.player}
        />
    )
};

export default LayoutPlayer;

RcMultiScreenPlayer

多屏播放器在线demo

属性说明类型默认值
className样式
defaultSelectedScreen默认分配数量1 | 4 | 6 | 8 | 9 | 12 | 13 | 16;4
defaultPlayerConfig视频播放基础属性{ // 协议类型 protocol?: Protocol | false | { defaultValue: Protocol, options: Array }, // 视频拉伸方式 objectFit?: ObjectFit | false | { defaultValue: ObjectFit, options: Array }; // 是否播放时长 maxPlayerTime?: MaxPlayerTime | false | { defaultValue: MaxPlayerTime, options: Array }, // 视频分辨率 resolution?: Resolution | false | { defaultValue: Resolution, options: Array } // 视频工具栏 videoToolbar?: { close?: boolean; // 是否可关闭 screenshot?: boolean; // 是否可截图 fullScreen?: boolean; // 是否支持全屏 }}{protocol: 'FLV',maxPlayerTime: 'forever'objectFit: 'fill'resolution: '720P'}
currentConfigplayer基础属性+RcMultiPlayer属性
id标识stringmulti-screen-player
events事件订阅基础属性events

Usage

import * as React from 'react';
import { Button, FormControl, InputLabel, MenuItem, Select, TextField } from "@mui/material";
import { RcMultiScreenPlayer } from "../src";
import Snackbar from "@mui/material/Snackbar";
import { useRef } from "react";

type RcMultiScreenPlayerTestProps = {};
const RcMultiScreenPlayerTest: React.FC<RcMultiScreenPlayerTestProps> = (props) => {
    const [protocol, setProtocol] = React.useState<any>('FLV');
    const [open, setOpen] = React.useState(false);
    const [currentConfig, setCurrentConfig] = React.useState<any>();
    const screenRef = useRef(null);
    const handleChange = (v: any) => {
        setProtocol(v?.target?.value);
    }
    const onClick = (e: any) => {
        // @ts-ignore
        const url = document.querySelector('#outlined-basic')?.value;
        // @ts-ignore
        const title = document.querySelector('#outlined-title')?.value;
        if (url) {
            setCurrentConfig({
                mediaDataSource: { url: url, type: 'flv', },
                playerConfig: { protocol: protocol, title: title, extraParams: { test: 1 }, layoutIndex: '0' }
            });
        } else {
            setOpen(true)
        }
    }
    return (
        <div style={{ height: 600 }}>
            <div style={{ display: 'flex' }}>
                <div style={{ flex: 1 }}>
                    <div style={{ width: '90%' }} className={'form'}>
                        <FormControl fullWidth className={'form-item'}>
                            <InputLabel id="demo-simple-select-label">协议类型</InputLabel>
                            <Select
                                labelId="demo-simple-select-label"
                                id="demo-simple-select"
                                value={protocol}
                                label="Age"
                                onChange={handleChange}
                            >
                                <MenuItem value={'FLV'}>FLV</MenuItem>
                                <MenuItem value={'WebRTC'}>WebRTC</MenuItem>
                            </Select>
                        </FormControl>
                        <FormControl fullWidth className={'form-item'}>
                            <TextField defaultValue={'title'} id="outlined-title" label="视频title"
                                       variant="outlined"/>
                        </FormControl>
                        <FormControl fullWidth className={'form-item'}>
                            <TextField defaultValue={'/live/40491879758-1-30002.flv'} id="outlined-basic" label="url地址"
                                       variant="outlined"/>
                        </FormControl>
                        <FormControl fullWidth className={'form-item'}>
                            <Button onClick={onClick} type={'submit'} id="form-submit"
                                    variant="outlined">
                                提交
                            </Button>
                        </FormControl>
                    </div>
                </div>
                <div style={{ flex: 3, height: 600 }}>
                    <RcMultiScreenPlayer
                        events={{
                            onReload: (e) => {
                                onClick(e);
                            },
                            onClose: (e) => {
                                console.log(222, e);
                            }
                        }}
                        defaultPlayerConfig={{
                            protocol: false,
                            maxPlayerTime: {
                                defaultValue: '3min',
                                options: [{
                                    label: '3分钟',
                                    value: '3min'
                                }]
                            },
                            objectFit: 'cover'
                        }}
                        ref={screenRef}
                        currentConfig={currentConfig}
                        defaultSelectedScreen={4}/>
                </div>
            </div>
            <Snackbar
                anchorOrigin={{ vertical: 'top', horizontal: 'left' }}
                open={open}
                autoHideDuration={6000}
                onClose={() => setOpen(false)}
                message="请输入播放地址"
            />
        </div>
    )
};

export default RcMultiScreenPlayerTest;
1.3.6-alpha.11

22 hours ago

1.3.6-alpha.9

13 days ago

1.3.6-alpha.6

14 days ago

1.3.6-alpha.7

14 days ago

1.3.6-alpha.8

14 days ago

1.3.6-alpha.5

2 months ago

1.3.5-alpha.3

3 months ago

1.3.5-alpha.2

3 months ago

1.3.5-alpha.5

3 months ago

1.3.5-alpha.4

3 months ago

1.3.5

3 months ago

1.3.5-alpha.1

4 months ago

1.3.5-alpha.0

4 months ago

1.3.4-alpha.9

5 months ago

1.3.4-alpha.8

5 months ago

1.3.4-alpha.7

5 months ago

1.3.4-alpha.6

5 months ago

1.3.4-alpha.4

5 months ago

1.3.4-alpha.3

5 months ago

1.3.4-alpha.2

5 months ago

1.3.4-alpha.1

5 months ago

1.3.4-alpha.0

5 months ago

1.3.2

5 months ago

1.3.1-alpha.1

5 months ago

1.3.0

5 months ago

1.3.1-alpha.0

5 months ago

1.2.3-alpha.0

10 months ago

1.2.3-alpha.1

10 months ago

1.2.3-alpha.2

10 months ago

1.2.7-alpha.19

10 months ago

1.2.7

10 months ago

1.2.7-alpha.18

10 months ago

1.2.7-alpha.17

10 months ago

1.2.7-alpha.16

10 months ago

1.2.5

10 months ago

1.2.7-alpha.15

10 months ago

1.2.4

10 months ago

1.2.7-alpha.14

10 months ago

1.2.3

10 months ago

1.2.7-alpha.13

10 months ago

1.2.7-alpha.12

10 months ago

1.2.1

10 months ago

1.2.16-alpha.8

9 months ago

1.2.3-alpha.3

10 months ago

1.2.16-alpha.7

9 months ago

1.2.3-alpha.4

10 months ago

1.2.3-alpha.5

10 months ago

1.2.1-alpha.0

11 months ago

1.2.19-alpha.1

6 months ago

1.2.19-alpha.0

7 months ago

1.2.17-alpha.0

9 months ago

1.2.7-alpha.11

10 months ago

1.2.7-alpha.10

10 months ago

1.2.13

9 months ago

1.2.10

10 months ago

1.2.11

9 months ago

1.2.16

9 months ago

1.2.17

8 months ago

1.2.15

9 months ago

1.2.2-alpha.0

10 months ago

1.2.18

8 months ago

1.2.7-alpha.6

10 months ago

1.2.7-alpha.5

10 months ago

1.2.7-alpha.4

10 months ago

1.2.7-alpha.3

10 months ago

1.2.7-alpha.2

10 months ago

1.2.7-alpha.1

10 months ago

1.2.7-alpha.0

10 months ago

1.2.7-alpha.9

10 months ago

1.2.7-alpha.8

10 months ago

1.2.7-alpha.7

10 months ago

1.2.0

11 months ago

1.0.2

1 year ago

0.9.6

1 year ago

1.0.2-alpha.10

1 year ago

0.8.5

1 year ago

0.6.7

1 year ago

0.5.8

2 years ago

0.8.4

1 year ago

0.7.5

1 year ago

0.6.6

1 year ago

0.5.7

2 years ago

0.6.9

1 year ago

0.6.10

1 year ago

0.6.12

1 year ago

0.6.11

1 year ago

0.6.18

1 year ago

0.6.17

1 year ago

0.6.19

1 year ago

0.6.14

1 year ago

0.6.13

1 year ago

0.6.16

1 year ago

0.6.15

1 year ago

0.8.1

1 year ago

0.5.4

2 years ago

0.6.2

1 year ago

0.5.3

2 years ago

0.8.3

1 year ago

0.6.5

1 year ago

0.5.6

2 years ago

0.8.2

1 year ago

0.7.3

1 year ago

0.6.4

1 year ago

0.5.5

2 years ago

0.5.0

2 years ago

0.7.0

1 year ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.8

2 years ago

0.4.6

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago