Magic Leap

Updated

integrate Video SDK for Unity to your Magic Leap app.

Agora Video SDK for Magic Leap allows you to integrate real-time Broadcast Streaming features into your Magic Leap app. You can enhance the overall user experience and add new possibilities for collaboration and interaction within Magic Leap environments.

This page shows the minimum code you need to integrate high-quality, low-latency Broadcast Streaming features into your Magic Leap project using Video SDK.

Understand the tech

This section explains how you can integrate Broadcast Streaming features into your Magic Leap project using Video SDK. The following figure shows the workflow you need to integrate this feature into your app.

To start a session, implement the following steps in your app:

  • Retrieve a token: A token is a computer-generated string that authenticates a user when your app joins a channel. In a test or production environment, your app retrieves tokens from a server in your security infrastructure.
  • Join a channel: Call methods to create and join a channel; apps that pass the same channel name join the same channel.

Prerequisites

In order to follow this procedure, you must have:

To test the code used in this page you need to have:

  • An Agora account and project.

  • A computer with Internet access. Ensure that no firewall is blocking your network communication.

  • Implemented the SDK quickstart

Project setup

To integrate Broadcast Streaming into your Magic Leap project, do the following:

  1. Create a Magic Leap project for Unity

In Unity Editor:

  1. Configure your project

In Unity Editor:

  1. Click Edit > Project settings.
  2. In XR Plug-in Management, enable Magic Leap.
  3. In XR Plug-in Management > Magic Leap Settings, enable Use ML Audio.
  4. In Player settings > Android > Publishing settings, enable Custom Main Manifest.
  5. In Magic Leap > Permissions, enable android.permission.CAMERA and android.permission.RECORD_AUDIO.

You are ready to add Broadcast Streaming features to your Magic Leap project.

Integrate the Broadcast Streaming demo

When a user opens the app, you initialize Agora Engine. When the user taps a button, the app joins or leaves a channel. When another user joins the same channel, their video and audio is rendered in the app. This simple workflow enables you to concentrate on implementing Agora features and not UX bells and whistles.

This section shows how to integrate the Video SDK to implement the Broadcast Streaming demo into your Magic Leap project.

  1. Download the latest version of Video SDK for Magic Leap to a local folder.

  2. Double-click the download package.

The Import dialog opens automatically in Unity Editor.

  1. Click Import.

In Project > Assets you see Agora-RTC-Plugin and Agora_MagicLeap2_Plugin.

You are ready to test the demo.

Test your implementation

Agora recommends you run this project on a physical mobile device, as some simulators may not support the full features of this project. To ensure that you have implemented Broadcast Streaming in your app:

  1. Obtain an App ID with token enabled.

  2. Generate a temporary token in Agora Console.

  3. In your browser, navigate to the Agora web demo and update App ID, Channel, and Token with the values for your temporary token, then click Join.

  4. In Unity Editor, double-click Agora_MagicLeap2_Plugin > AgoraEngine > ML2Support > Demo.

The demo scene opens.

  1. In Project, open Agora_MagicLeap2_Plugin > AgoraEngine > ML2Support > Scripts > Agora Controller.

  2. Update APP_ID, TOKEN, and CHANNEL_NAME with the same values you used for the web demo.

  3. Connect an ML2 device, then click Build and Run.

The demo app opens.

  1. Click Connect Camera.

Video from your ML2 is streamed to the channel and is visible in the web demo. You see the video stream from the web demo.

Now you have tested the demo, best practice is to customize the demo source including the custom audio and video handling into your Magic Leap 2 project.

Reference

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

  • Manual install shows you how to install Video SDK manually.

  • To ensure communication security in a test or production environment, best practice is to use a token server to ensure communication security, see Secure authentication with tokens.

API reference