Code Monkey home page Code Monkey logo

Comments (11)

dprisikar avatar dprisikar commented on June 12, 2024 1

@SangwonOh, thank you for checking up on me. Yes, I have managed to find a solution.

from ovenlivekit-web.

IanMitchell77 avatar IanMitchell77 commented on June 12, 2024

I guess that its not streaming at the point you call getAudioTracks so you need to check that it returns something before calling the enable function.

from ovenlivekit-web.

dprisikar avatar dprisikar commented on June 12, 2024

@IanMitchell77 , thanks again for helping me out!

As soon as the page loads, the microphone is accessed, and a little red dot indicator at the top of the page, where the page tab is, appears.

Plus, the console returns "OvenLiveKit.js : Received Media Stream From Input Device", with MediaStream {id, ...}

To my understanding, this means that the audio is streaming.

Here is the page code for reference; this is the latest version, as is (I have tried accessing the audio stream with MediaStream.getAudioTracks[0], but the result is the same):

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    
    <link rel="stylesheet" href="style.css">
    
</head>

<body class="text-center body-centered">

  <main class="form-centered">
    <form>
      <div class="form-floating mb-4">
        <input type="button" class="button-publish" id="muteBtn" value="GO LIVE">
      </div>
       </form>  
  </main>

<!-- Voice capture script -->
<script src="https://cdn.jsdelivr.net/npm/ovenlivekit@latest/dist/OvenLiveKit.min.js"></script><script defer="defer" src="fda0b8224f3acb87a87b.bundle.js"></script>
   
<script>
// Initialize OvenLiveKit
let ovenLivekit = OvenLiveKit.create();
// Get media stream from user device
ovenLivekit.getUserMedia({video: false, audio: true}).then(function () {
    // Got device stream and start streaming to OvenMediaEngine
    ovenLivekit.startStreaming('wss://your_oven_media_engine:3333/app/stream?direction=send');
});

document.getElementById("muteBtn").onclick = function(evt) {
const newState = !MediaStream.getAudioTracks[0].enabled;
document.getElementById("muteBtn").innerHTML = newState ? "&#x25B6;&#xFE0F;" : "&#x23F8;&#xFE0F;";
MediaStream.getAudioTracks[0].enabled = newState;
 }
</script>

<!-- Bootstrap script -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
  

</body></html>

from ovenlivekit-web.

IanMitchell77 avatar IanMitchell77 commented on June 12, 2024

hang on! MediaStream isnt anything - maybe it should be ovenLivekit?

from ovenlivekit-web.

IanMitchell77 avatar IanMitchell77 commented on June 12, 2024

Try printing the contents of MediaStream, and MediaStream.getAudioTracks[0]

from ovenlivekit-web.

dprisikar avatar dprisikar commented on June 12, 2024

Running console.log(ovenLiveKit.stream);

This returns MediaStream {...}, but when trying to access getAudioTracks, the console logging returns "undefined".

from ovenlivekit-web.

dprisikar avatar dprisikar commented on June 12, 2024

image_2022-07-11_13-39-47

from ovenlivekit-web.

IanMitchell77 avatar IanMitchell77 commented on June 12, 2024

You want to check that the length is not 0 - I guess you need to add the track first but I dont know anything about OvenLiveKit to be honest.

from ovenlivekit-web.

dprisikar avatar dprisikar commented on June 12, 2024

Thank you, @IanMitchell77 for your input, definitely, appreciate it!

from ovenlivekit-web.

SangwonOh avatar SangwonOh commented on June 12, 2024

@dprisikar Hi. Is your problem solved?

from ovenlivekit-web.

owengiri20 avatar owengiri20 commented on June 12, 2024

@SangwonOh, thank you for checking up on me. Yes, I have managed to find a solution.

Hi, what was your solution? (I'm having a similar issue)

from ovenlivekit-web.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.