Skip to content

Commit bad6717

Browse files
fix: 修复 alirts 播放脚本报错问题 🐛
1 parent a51f952 commit bad6717

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

example/src/App.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Scrollbars } from 'react-custom-scrollbars';
66

77
import Hls from 'hls.js';
88
import flvjs from 'flv.js';
9-
import { AliRTS } from 'aliyun-rts-sdk';
9+
import { AliRTS } from 'aliyun-rts-sdk/dist/aliyun-rts-sdk-without-adapter.js';
1010
import ReactjsPlayer from 'reactjs-player';
1111
// import grindPlayerSwf from 'reactjs-player/dist/GrindPlayer.swf';
1212
// import flashlsOSMFSwf from 'reactjs-player/dist/flashlsOSMF.swf';
@@ -44,7 +44,7 @@ const getSupportedList = (ua) => {
4444
key: 'alirts',
4545
kernel: 'alirts',
4646
live: true,
47-
src: 'rtmp://livetv.dhtv.cn:1935/live/news',
47+
src: 'artc://a.lcdn.opensight.cn/alicdn/LULAyun4Q0ibCpSuj1vSrw?auth_key=1687020149-0-0-fc7129da8b191fb3c1c08805ca5fa3ee',
4848
type: '',
4949
},
5050
{
@@ -129,7 +129,6 @@ const App = React.memo(() => {
129129
ref.current = supportedList;
130130
setInfo(supportedList[0]);
131131
// NOTE: 测试自动播放的情况
132-
console.log(`type: ${supportedList[0].key}`);
133132
onSubmit({ type: supportedList[0].key, src: supportedList[0].src });
134133
}, [onSubmit]);
135134

@@ -153,10 +152,7 @@ const App = React.memo(() => {
153152
layout="inline"
154153
form={form}
155154
onFinish={onSubmit}
156-
initialValues={{
157-
type: list[0].key,
158-
src: list[0].src,
159-
}}
155+
initialValues={{ type: info.key, src: info.src }}
160156
>
161157
<Form.Item className="type" name="type">
162158
<Select onChange={onChange}>

src/AliRTS/useAliRTS.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default ({ getVideoElement, src, config, onMsgChange }) => {
7171
const cleanup = () => destroyPlayer(player);
7272
const currentSrc = ref.current;
7373
const el = getVideo.current();
74-
if (!el) {
74+
if (!el || !player) {
7575
return cleanup;
7676
}
7777

src/ReactjsPlayer/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const ReactjsPlayer = ({
117117
};
118118

119119
ReactjsPlayer.propTypes = {
120-
kernel: PropTypes.oneOf(['hlsjs', 'flvjs', 'native', 'srswebrtc']).isRequired,
120+
kernel: PropTypes.oneOf(['srswebrtc', 'alirts', 'flvjs', 'hlsjs', 'native']).isRequired,
121121
live: PropTypes.bool.isRequired,
122122
config: PropTypes.object,
123123
onKernelError: PropTypes.func,

0 commit comments

Comments
 (0)