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:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart
- Unity Hub
- Unity Editor 2017.X LTS or higher
- Microsoft Visual Studio 2017 or higher
- Installed ML Hub
- Installed Unity Hub
- Install and configure the Unity Editor required to develop for Magic Leap 2
Project setup
To integrate Broadcast Streaming into your Magic Leap project, do the following:
- Create a Magic Leap project for Unity
In Unity Editor:
- Create a project for your Agora Magic Leap app.
- Configure your app settings
- Configure your project
In Unity Editor:
- Click Edit > Project settings.
- In XR Plug-in Management, enable Magic Leap.
- In XR Plug-in Management > Magic Leap Settings, enable Use ML Audio.
- In Player settings > Android > Publishing settings, enable Custom Main Manifest.
- In Magic Leap > Permissions, enable
android.permission.CAMERAandandroid.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.
-
Download the latest version of Video SDK for Magic Leap to a local folder.
-
Double-click the download package.
The Import dialog opens automatically in Unity Editor.
- 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:
-
Obtain an App ID with token enabled.
-
Generate a temporary token in Agora Console.
-
In your browser, navigate to the Agora web demo and update
App ID,Channel, andTokenwith the values for your temporary token, then click Join. -
In Unity Editor, double-click Agora_MagicLeap2_Plugin > AgoraEngine > ML2Support > Demo.
The demo scene opens.
-
In Project, open Agora_MagicLeap2_Plugin > AgoraEngine > ML2Support > Scripts > Agora Controller.
-
Update
APP_ID,TOKEN, andCHANNEL_NAMEwith the same values you used for the web demo. -
Connect an ML2 device, then click Build and Run.
The demo app opens.
- 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.
