Bug: start audio on

by ShukantPal

HTML

<html>
  <head>
  <script src="https://unpkg.com/@daily-co/[email protected]"></script>
  </head>
  <body>
  </body>
</html>

JavaScript

const ROOM_URL = "https://jpt.staging.daily.co/hello";
const API_KEY = '8f7d0f624285130ba5ec56e8a037448af282b37982d051c457d5388bb1671a51';

async function main(e) {
  const devices = await navigator
    .mediaDevices
    .enumerateDevices();
  const audioSource = devices
  	.find((device) => device && device.kind === 'audioinput');
  console.log('Using audio device: ', audioSource.deviceId);

	const call = DailyIframe.createCallObject({
    subscribeToTracksAutomatically: false,
  	/* audioSource: audioSource.deviceId, */
  });
  
  window.call = call;
  
	const token = await fetchMeetingToken();
  call.once('joined-meeting', () => {
    console.log('[INIT] Joined meeting');
    call.setLocalAudio(true);
  });
  await call.join({
  	url: ROOM_URL,
    token,
  });
  
  console.log("[READY] now run window.call.localAudio()");
}

async function fetchMeetingToken() {
  const options = {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${API_KEY}`,
    },
    body: JSON.stringify({
      properties: {
        room_name: 'hello',
        is_owner: true,
        start_audio_off: true,
        start_video_off: true,
      },
    }),
  };

  const dailyRes = await fetch(
    'https://api.staging.daily.co/v1/meeting-tokens',
    options
  );
  const {
    token
  } = await dailyRes.json();
  console.log("[INIT] Token fetched ", token);
  
  return token;
}

main();