Software Archive
Read-only legacy content
17061 Discussions

How to create video chat app (video streaming) using WebRTC concept in intel XDK

Anjali_P_
Beginner
300 Views

Hii..

I want to create a video chat app using WebRTC concept in intel XDK. I have done sample of video streaming. I have created two buttons : One button will take the video and other will paused the video. This sample works well in the emulator but neither testing nor after building the app. Please help me as soon as possible.

The following is the code : 

JAVASCRIPT CODE :

main.js

function playVideo()
{
    var media = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || null;
    var video_audio_properties = {video: true, audio: true};
    if(media !== null)
          media(video_audio_properties, onSuccess, onError);
    else
        alert("not supported");
    function onSuccess(stream)
    {
        document.getElementById("videoID").src = window.URL.createObjectURL(stream);
        document.getElementById("videoID").play();
    }
    function onError(error)
    {
        console.log("Video capture error: ", error.code);
    }
}
function pauseVideo()
{
    document.getElementById("videoID").pause();

HTML CODE :

<!DOCTYPE html>
<html>
<head>
    <title>Blank Cordova Mobile App Project Template (Lite)</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <style>
        @-ms-viewport { width: 100vw ; zoom: 100% ; }  @viewport { width: 100vw ; zoom: 100% ; }
        @-ms-viewport { user-zoom: fixed ; }           @viewport { user-zoom: fixed ; }
    </style>
    <script src="cordova.js"></script>         
    <script src="js/app.js"></script>          
    <script src="xdk/init-dev.js"></script>     
    <script src="js/main.js"></script>
</head>
<body>
    <div>
        <video id = "videoID" style="height:200px; width:200px; border : solid 1px aqua;"></video>
    </div><br>
    <button id="btn1" onclick = "playVideo();">Play Video</button>
    <button id="btn2" onclick = "pauseVideo();">Pause Video</button>
</body>
</html>

 

0 Kudos
2 Replies
Anusha_M_Intel1
Employee
300 Views

We have a WebRTC chat sample app you can check out. It ships with the XDK and is called 'WebRTCSDK Video Chat Sample'. 

Or here is the git repo: https://github.com/gomobile/sample-webrtc-chat

0 Kudos
Arif_B_
Beginner
300 Views

Hi,

I have built the webRTC sample app, however once I am logged in with my Yahoo account it is asking for a Connectto Friend ID, how should I create the IDs?

Pls assist

Arif

0 Kudos
Reply