# Magic Leap (/en/realtime-media/broadcast-streaming/reference/magic-leap)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Agora Video SDK for Magic Leap allows you to integrate real-time Broadcast Streaming features into your [Magic
Leap](https://www.magicleap.com/) 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 [#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 [#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](../manage-agora-account) and [project](../manage-agora-account).

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

* Implemented the [SDK quickstart](../index)

- [Unity Hub](https://unity.com/download)
- [Unity Editor 2017.X LTS or higher](https://unity.com/releases/editor/archive)
- Microsoft Visual Studio 2017 or higher

* Installed [ML Hub](https://developer-docs.magicleap.cloud/docs/guides/getting-started/install-the-tools)
* Installed [Unity Hub](https://unity.com/download)
* [Install and configure the Unity Editor required to develop for Magic Leap 2](https://developer-docs.magicleap.cloud/docs/guides/unity/getting-started/install-the-tools)

## Project setup [#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:

* [Create a project](https://developer-docs.magicleap.cloud/docs/guides/unity/getting-started/create-a-project)
  for your Agora Magic Leap app.
* [Configure your app settings](https://developer-docs.magicleap.cloud/docs/guides/unity/getting-started/configure-unity-settings)

2. **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 [#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](../../../sdks) 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.

3. Click **Import**.

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

You are ready to test the demo.

## Test your implementation [#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](../manage-agora-account) in Agora Console.

3. In your browser, navigate to the [Agora web demo](https://webdemo.agora.io/basicVideoCall/index.html) 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.

5. In **Project**, open **Agora\_MagicLeap2\_Plugin** > **AgoraEngine** > **ML2Support** > **Scripts** > **Agora
   Controller**.

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

7. Connect an ML2 device, then click **Build and Run**.

The demo app opens.

8. 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 [#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](../../../sdks) 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](../build/authenticate-users/use-tokens).

### API reference [#api-reference]

* [JoinChannel](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_joinchannel)

* [EnableVideo](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_enablevideo)

* [CreateAgoraRtcEngine](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_createagorartcengine)

* [InitEventHandler](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_addhandler)

* [SetClientRole](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_setclientrole)

* [LeaveChannel](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_leavechannel)

* [DisableVideo](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_disablevideo)

* [PushVideoFrame](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_imediaengine_pushvideoframe)

* [PushAudioFrame](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_imediaengine_pushaudioframe0)

* [PullAudioFrame](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_imediaengine_pullaudioframe)
