Skip to content

Latest commit

 

History

History
173 lines (118 loc) · 8.97 KB

setup-guide.md

File metadata and controls

173 lines (118 loc) · 8.97 KB

QuickStart Guide

Getting started with HISPlayer consists of implementing the following steps:

  1. Import and configure package

    1.1. Import package

    1.2. Configure Unity for iOS

  2. Create your own sample

    2.1 Setup HISPlayer Manager

    2.2 Attach Unity Resources

    2.3 Configure HISPlayer Properties

    2.4 Build and Run

It's also possible to import the HISPlayer Sample after completing step 1. The sample is a comprehensive example scene using the HISPlayerSDK to help demonstrate features like play, pause, seek, etc.

1.1 Import package

HISPlayer SDK versions 3.4.0 and above

The HISPlayer Sample is included in the HISPlayer SDK Unity Package.

Importing the package is the same as importing other normal packages in Unity. Select the package of HISPlayer SDK and import it.

Assets > Import Package > Custom Package > HISPlayerSDK unity package

Refer to Import HISPlayer Sample to know more about the HISPlayer Sample.

In the case you don't want to include the HISPlayer Sample, please disable it from the Import Unity Package window.

HISPlayer SDK versions 3.3.0 and below

Importing the package is the same as importing other normal packages in Unity. Select the package of HISPlayer SDK and import it.

Assets > Import Package > Custom Package > HISPlayerSDK unity package

Only the SDK will be imported using HISPlayer SDK versions lower than 3.4.0. Refer to Import HISPlayer Sample to know more about the HISPlayer Sample.


1.2 Configure Unity for iOS

Open the window Tools > HISPlayer located in the upper side of the screen > Click on Player Settings Configuration > Select Build Target to iOS > Set all the required settings.

image

image

Please go to Packages > HISPlayerSDK > HISPlayer > Plugins > iOS. Make sure that the HISPlayeriOS.framework file has the Add to Embedded Binaries set to true.

2.1 Set up HISPlayer Manager

You may skip this section if you are using HISPlayerSample. The code set-up is already included in the sample script (HISPlayerSample.cs).

Create a new script which will inherit from HISPlayerManager, for example, iOSStreamController. It is necessary to add the 'using HISPlayerAPI;' dependancy. Then, add this component to a new game object (recommended to be empty).

Call the SetUpPlayer() function in order to initialize the stream environment internally. This function can be called whenever it’s needed.

For example, using the Awake function:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HISPlayerAPI;

public class iOSStreamController : HISPlayerManager
{
    protected override void Awake()
    {
        base.Awake();
        SetUpPlayer();
    }
}

It is strictly necessary to use SetUpPlayer before using anything else. This function initializes everything else that will be needed during the usage of HISPlayer APIs.

Remember to call the Release function after closing the app or before changing scenes in Unity for freeing the internal resources.

2.2 Attach Unity resources

Move to Unity Editor to attach all the resources. The rendering system is supporting Material, RawImage and RenderTexture Unity’s components.

Material

Create a new Material from Assets > Create > Material and attach it to the GameObject that is going to be used as screen and to the stream controller component.

You can also use the Resources > Materials > HISPlayerDefaultMaterial.mat we provide in our package.

image image

Raw Image

This action will be related to Unity’s Canvas. If there is not a Canvas created yet, creating a Raw Image will create one automatically.

For the creation, select GameObject > UI > Raw Image. Once it is created, attach it to the stream controller component

image

RenderTexture

For this you can use the RenderTexture we provide or create a RenderTexture from zero. In the first case, go to the Resources folder of our package and attach the Resources > Materials > HISPlayerDefaultMaterialRenderTexture.mat to the GameObject that is going to be used as screen and the Resources > RenderTextures > HISPlayerRenderTexture.renderTexture to the stream controller component.

For creating it from zero, select Assets > Create > Render Texutre and then create a Material referencing the Render Texture. This last action can be done automatically by grabbing the Render Texture and dropping it at the end of a GameObject's Inspector with the component Mesh Renderer with Material field empty. This will create the new material inside a Materials folder.

Once all this process it’s done, associate the RenderTexture to the script component.

2.3 Configure HISPlayer Properties

License Key

If you received a license key from HISPlayer, please input the license key in the License Key field.

If the license key is not valid, the player won't work and will throw an error message. License key is not required for Unity Editor usage.

Multi Stream Properties

Use Multi Stream Properties to set all configurations needed for multi streams. It starts with 0 elements. Each element added has its own configuration for multiple players and corresponds to 1 Render Surface. If you just need a single stream, then you just need to add 1 element with 1 URL.

  • Render Mode: Select the render surface. It can be RenderTexture, Material, RawImage or NONE.
  • Material: Attach the Material asset created to the Material section of the element.
  • Raw Image: Attach the RawImage asset created to the RawImage section of the element.
  • Render Texture: Attach the RenderTexture to the RenderTexture section of the element.
  • URL: Add the URL associated to the stream. Each stream can have multiple URLs, therefore users can use the same render surface to play different URLs. It is also possible to add local files allocated in the device’s storage and the StreamingAssets special folder of Unity (see Playing Local Files for more details).
  • URL MIME Types: Set the MIME types of each URL. Only using URL Extension or HLS is supported for iOS. URL Extension is set by default.
  • Autoplay: Property to determine whether the player will start automatically after set up.
  • Loop Playback: Property to loop the current playback. It’s true by default.
  • Auto Transition: Property to change the playback to the next video in the playlist. This action won’t have effect when loopPlayback is true. It’s false by default.
  • Digital Rights Management (DRM): The DRM will be disabled by default. See DRM for more details.

2.4 Build and Run:

Once the configuration it’s done, open ‘Build Settings’ and press ‘Build And Run’.

Please deploy to real iPhone device. Xcode iPhone simulator build is not supported.