我正試圖在瀏覽器之間進行1:1的opentok對接。與OpenTok 1:1對話出現的問題
有兩個角色:
一個發佈者邀請和一個被邀請者。目的是讓這兩個人進行1:1的對話。
會話正確進行,被邀請者連接到流。被邀請者接收發布者的視頻流並將其添加到其容器中。然後他開始發佈到同一個會話。 (yay)...
但是,發佈者只能看到他自己的視頻。我根本無法檢測到被邀請者發佈的流。
繼承人的出版商功能:
function startVideoHost(sessionId, apiKey, token) {
var replacementElementId = "localVideo";
if (OT.checkSystemRequirements() == 1) {
publisher = OT.initPublisher(replacementElementId);
publisher.on({
streamCreated: function (event) {
$('.videoWindow').show();
console.log("Publisher started streaming.");
},
streamDestroyed: function (event) {
console.log("Publisher stopped streaming. Reason: "
+ event.reason);
}
});
// this is kinda where id hope the publisher would detect the guest stream
session = OT.initSession(apiKey, sessionId);
session.on("streamCreated", function(event) {
session.subscribe(event.stream, remoteVideos);
});
session.connect(token, function (error) {
if (session.capabilities.publish == 1) {
session.publish(publisher);
} else {
console.log("You cannot publish an audio-video stream.");
}
});
} else {
console.log("The client does not support WebRTC.");
}
}
而且繼承人受邀功能:
function startVideoGuest(sessionId, apiKey, token) {
if (OT.checkSystemRequirements() == 1) {
var session = OT.initSession(apiKey, sessionId);
session.on("streamCreated", function(event) {
session.subscribe(event.stream, remoteVideos);
});
session.connect(token, function(error) {
if (error) {
console.log("Error connecting: ", error.code, error.message);
} else {
$('.videoWindow').show();
var replacementElementId = "localVideo";
publisher = OT.initPublisher(replacementElementId);
publisher.on({
streamCreated: function (event) {
console.log("Publisher started streaming.");
},
streamDestroyed: function (event) {
console.log("Publisher stopped streaming. Reason: "
+ event.reason);
}
});
console.log("Connected to the session.");
}
});
}
}
沒有人有任何想法,爲什麼我不是讓被邀請者視頻流返回給發佈者?
現貨,謝謝一堆:) – Havihavi