创建新仓库
This commit is contained in:
75
static/webrtc.html
Normal file
75
static/webrtc.html
Normal file
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>SRS</title>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
body {
|
||||
padding-top: 30px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="/static/lib/webrtc/css/bootstrap.min.css" />
|
||||
<script type="text/javascript" src="/static/lib/webrtc/jquery-1.12.2.min.js"></script>
|
||||
<script type="text/javascript" src="/static/lib/webrtc/adapter-7.4.0.min.js"></script>
|
||||
<script type="text/javascript" src="/static/lib/webrtc/srs.sdk.js"></script>
|
||||
<script type="text/javascript" src="/static/lib/webrtc/winlin.utility.js"></script>
|
||||
<script type="text/javascript" src="/static/lib/webrtc/srs.page.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="form-inline">
|
||||
URL:
|
||||
<input type="text" id="txt_url" class="input-xxlarge" title="WHEP URL" placeholder="Enter WHEP URL here"
|
||||
value="http://192.168.110.43:1985/rtc/v1/whep/?app=live&stream=1581F5FHC249900DLV0C-66-0-0">
|
||||
<button class="btn btn-primary" id="btn_play">Play</button>
|
||||
</div>
|
||||
<video id="rtc_media_player" controls autoplay></video>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var sdk = null; // Global handler to do cleanup when republishing.
|
||||
var startPlay = function () {
|
||||
$('#rtc_media_player').show();
|
||||
|
||||
// Close PC when user replay.
|
||||
if (sdk) {
|
||||
sdk.close();
|
||||
}
|
||||
sdk = new SrsRtcWhipWhepAsync();
|
||||
|
||||
// User should set the stream when publish is done, @see https://webrtc.org/getting-started/media-devices
|
||||
// However SRS SDK provides a consist API like https://webrtc.org/getting-started/remote-streams
|
||||
$('#rtc_media_player').prop('srcObject', sdk.stream);
|
||||
// Optional callback, SDK will add track to stream.
|
||||
// sdk.ontrack = function (event) { console.log('Got track', event); sdk.stream.addTrack(event.track); };
|
||||
|
||||
// For example: webrtc://r.ossrs.net/live/livestream
|
||||
var url = $("#txt_url").val();
|
||||
sdk.play(url).then(function (session) {
|
||||
$('#sessionid').html(session.sessionid);
|
||||
$('#simulator-drop').attr('href', session.simulator + '?drop=1&username=' + session.sessionid);
|
||||
}).catch(function (reason) {
|
||||
sdk.close();
|
||||
$('#rtc_media_player').hide();
|
||||
console.error(reason);
|
||||
});
|
||||
};
|
||||
|
||||
$('#rtc_media_player').hide();
|
||||
var query = parse_query_string();
|
||||
srs_init_whep("#txt_url", query);
|
||||
|
||||
$("#btn_play").click(startPlay);
|
||||
// Never play util windows loaded @see https://github.com/ossrs/srs/issues/2732
|
||||
if (query.autostart === 'true') {
|
||||
$('#rtc_media_player').prop('muted', true);
|
||||
console.warn('For autostart, we should mute it, see https://www.jianshu.com/p/c3c6944eed5a ' +
|
||||
'or https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#audiovideo_elements');
|
||||
window.addEventListener("load", function () { startPlay(); });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user