publish local media error

Gabriel T

Member
Hello
i'm new to flashphoner which looks pretty promising, however i'm having some difficulties in implementing my own apps.
based on the conference example (web sdk), i'm stuck at the publish local media
connection, joining and messages are working ok. but when issuing the publishLocalMedia function, i got the following error:
WARN core - TypeError: Cannot read property 'children' of undefined
i just changed the id of the container div suppposed to receive the video. Any clue ?

thank you !
 
Hello

As you can see from conference.js code, ID of div-element is an important part of API.
https://github.com/flashphoner/flas.../demo/streaming/conference/conference.js#L159
Code:
 participant.getStreams()[0].play(document.getElementById(pDisplay)).on(STREAM_STATUS.PLAYING, function (playingStream) {
                    document.getElementById(playingStream.id()).addEventListener('resize', function (event) {
                        resizeVideo(event.target);
                    });
                });
Therefore, conference.js implementation wants to see IDs as participant1Display, participant2Display, etc.

The same for publishing stream.
https://github.com/flashphoner/flas...demo/streaming/conference/conference.html#L79
HTML:
 <div id="localDisplay" class="fp-localVideo"></div>
https://github.com/flashphoner/flas.../demo/streaming/conference/conference.js#L222
Code:
room.publish({
        display: document.getElementById("localDisplay"),
        constraints: constraints,
        record: false,
        receiveVideo: false,
        receiveAudio: false
    });

So if you change ID of div element in HTML, you have to change this ID in js file too.
 
of course i changed it in the conference.js too...here is my js command:

room.publish(document.getElementById("myVideo")).on(STREAM_STATUS.FAILED, function (stream) {

and of course there is a div called "myVideo"
 
Your code is incorrect:
Code:
room.publish(document.getElementById("myVideo"));
Correct code:
Code:
room.publish({display:document.getElementById("myVideo")});
 
ok, so it works with this command:

room.publish({
display: document.getElementById("myVideo"),
record: false,
receiveVideo: true,
receiveAudio: true
});

but not with the orignal command from conference.js : room.publish(document.getElementById("myVideo")).on(STREAM_STATUS.FAILED, function (stream) {...

any idea ?

also, how to attach event listener when using the first command ?

thank you !
 
its not my code, its the code found in conference.js:

function publishLocalMedia(room) {
room.publish(document.getElementById("localDisplay")).on(STREAM_STATUS.FAILED, function (stream) {
console.warn("Local stream failed!");
setStatus("#localStatus", stream.status());
onMediaStopped(room);
}).on(STREAM_STATUS.PUBLISHING, function (stream) {
setStatus("#localStatus", stream.status());
onMediaPublished(stream);
}).on(STREAM_STATUS.UNPUBLISHED, function(stream) {
setStatus("#localStatus", stream.status());
onMediaStopped(room);
});
}
 
but not with the orignal command from conference.js : room.publish(document.getElementById("myVideo"))
This code is incorrect. Could you say, where did you see such code? Would you give me a link.
also, how to attach event listener when using the first command ?
https://github.com/flashphoner/flas.../demo/streaming/conference/conference.js#L227
Code:
room.publish({
        display: document.getElementById("localDisplay"),
        constraints: constraints,
        record: false,
        receiveVideo: false,
        receiveAudio: false
    }).on(STREAM_STATUS.FAILED, function (stream) {
        console.warn("Local stream failed!");
        setStatus("#localStatus", stream.status());
        onMediaStopped(room);
    }).on(STREAM_STATUS.PUBLISHING, function (stream) {
        setStatus("#localStatus", stream.status());
        onMediaPublished(stream);
    }).on(STREAM_STATUS.UNPUBLISHED, function(stream) {
        setStatus("#localStatus", stream.status());
        onMediaStopped(room);
});
Here you are listening FAILED, PUBLISHING, UNPUBLISHED statuses.
 
stupid question: how to unpublish a stream...i tryed to publish with audio/video set to false, but looks like its not the way :D
 
Top