lemonshield-lib
v0.0.2
Published
Lemonshield common库 # dest "dest": "./dist/lemonshield-lib",
Readme
LemonshieldLib
Lemonshield common库
dest
"dest": "./dist/lemonshield-lib",
SrsRtc
webrtc 连接库 npm i srs-rtc
example
<video #rtcMediaPlayer id="rtc_media_player" controls autoplay>
import { SrsRtcService } from 'srs-rtc';
export class WebRtcComponent implements OnInit{ @ViewChild('rtcMediaPlayer', { static: true }) rtcMediaPlayer!: ElementRef; pc!: RTCPeerConnection;
constructor(private srsRtcService: SrsRtcService) {}
ngOnInit(): void { this.initialize() }
async initialize() { try { // Initialize the SRS RTC service this.srsRtcService.constraints = { audio: true, video: { width: { ideal: 320, max: 576 } } }; // Set the srcObject for the video element this.rtcMediaPlayer.nativeElement.srcObject = await this.srsRtcService.getStream(); // Play the stream const url = 'http://107.151.241.144:22022/rtc/v1/whep/?app=live&stream=0228871cc694&secret=4989E197C96E4ACB'; const session = await this.srsRtcService.play(url); } catch (error) { console.error('Publishing error:', error); this.srsRtcService.close(); this.rtcMediaPlayer.nativeElement.style.display = 'none'; } } }
