Skip to content

Commit

Permalink
Fix the issue where playback was not possible when reloading after st…
Browse files Browse the repository at this point in the history
…opping webrtc playback.

#370
  • Loading branch information
SangwonOh committed Jan 19, 2024
1 parent 77e824f commit af179c6
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/js/api/provider/html5/providers/WebRTCLoader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "utils/underscore";
import {analUserAgent} from "utils/browser";
import { analUserAgent } from "utils/browser";
import {
ERRORS,
PLAYER_WEBRTC_WS_ERROR,
Expand All @@ -15,17 +15,17 @@ import {
PEER_CONNECTION_PREPARED
} from "api/constants";
import sizeHumanizer from "../../../../utils/sizeHumanizer";
import {PEER_CONNECTION_DESTROYED} from "../../../constants";
import { PEER_CONNECTION_DESTROYED } from "../../../constants";


const WebRTCLoader = function (provider,
webSocketUrl,
loadCallback,
connectedCallback,
internalErrorCallback,
errorTrigger,
playerConfig,
spec) {
webSocketUrl,
loadCallback,
connectedCallback,
internalErrorCallback,
errorTrigger,
playerConfig,
spec) {

let defaultConnectionConfig = {};

Expand Down Expand Up @@ -673,7 +673,7 @@ const WebRTCLoader = function (provider,

if (message.command === 'ping') {

sendMessage(ws, {command: 'pong'});
sendMessage(ws, { command: 'pong' });
return;
}

Expand Down Expand Up @@ -759,9 +759,9 @@ const WebRTCLoader = function (provider,

let qualityIndex = -1;

for (let i = 0; i < playlistFromOme.renditions.length; i ++) {
for (let i = 0; i < playlistFromOme.renditions.length; i++) {

if (rendition.rendition_name === playlistFromOme.renditions[i].name) {
if (rendition.rendition_name === playlistFromOme.renditions[i].name) {
qualityIndex = i;
spec.currentQuality = i;
break;
Expand Down Expand Up @@ -949,6 +949,10 @@ const WebRTCLoader = function (provider,
return -1;
}

if (!mainPeerConnectionInfo) {
return -1;
}

let rendition = playlistFromOme.renditions[qualityIndex];

if (!rendition) {
Expand All @@ -975,6 +979,10 @@ const WebRTCLoader = function (provider,

provider.setAutoQuality = (auto) => {

if (!mainPeerConnectionInfo) {
return;
}

sendMessage(ws, {
command: 'change_rendition',
id: mainPeerConnectionInfo.id,
Expand Down

0 comments on commit af179c6

Please sign in to comment.