Stay organized with collections Save and categorize content based on your preferences.
The GVR SDK for Unity includes an additional GVR video plugin that supports streaming flat and 360° videos in both mono and stereo formats by using the ExoPlayer library to handle decoding and rendering of video, audio, and related streams. ExoPlayer provides all the standard playback framework for both videos embedded in your application and streaming videos, including adaptive streaming support, such as DASH and HLS.
Note: This plugin supports Daydream only. Configuring your video playerThe GVR SDK for Unity provides a C# script, called GvrVideoPlayerTexture
, that allows you to configure your video player. The script renders the video image into a texture created in Unity. The texture can then be placed on any mesh renderer in the scene.
To use the script, add it to a GameObject with a Mesh Renderer component. At runtime, the script creates another texture and uses that as the main texture of the renderer.
Player propertiesThe GvrVideoPlayerTexture
script allows you to adjust the following properties:
These examples demonstrate how to build a simple video player within VR.
PrerequisitesThe following steps set up the Daydream controller support, which all the video player examples require.
GvrEditorEmulator
to the scene, located under GoogleVR/Prefabs.GvrControllerMain
to the scene, located under GoogleVR/Prefabs/Controller.GvrControllerPointer
, located under GoogleVR/Prefabs/UI.GvrReticlePointer
, located under GoogleVR/Prefabs/UI.GvrPointerInputModule
script.This example shows how to create a flat video playback using DASH with a video hosted on Google Cloud Storage.
VideoMaterial
, or StereoMaterial
if the video is a stereoscopic video, located under GoogleVR/Demos/Materials/VideoDemo.GvrVideoTexturePlayer
script to the quad, located under GoogleVR/Scripts/Video.GvrVideoTextureplayer
as follows:
VideoControls
prefab, located under GoogleVR/Demos/Prefabs/VideoDemo.
At this point, your scene should have all the components as shown in the screenshot below.
Save the scene and open File > Build Settings.
Add the current scene to the scene list and make sure it's the first scene enabled.
Press Build & Run to run the example.
This example shows how to create a 360° video playback using DASH with a video hosted on Google Cloud Storage. To do this, we create a large sphere with the camera at the center and render the video on the inside of the sphere.
VideoStereoInside
, located under GoogleVR/Demos/Materials/VideoDemo.GvrVideoTexturePlayer
script to the sphere, located under GoogleVR/Scripts/VideoGvrVideoTextureplayer
script as follows:
VideoControls
prefab, located under GoogleVR/Demos/Prefabs/VideoDemo
Locally storing videos using Asset Manager is a viable option when your APK file is under 100 MB, the maximum allowed file size for apps on the Google Play Store, but it is not uncommon to have video assets exceeding this limit. To work around this limit, the resources can be stored in an OBB file as follows:
Place your video asset in Assets/StreamingAssets. Files in this folder will be copied unchanged to the target machine, where it then will be available from a specific folder. For more information, see Unity's documentation on Special Folders.
Change the Video Texture Player properties to:
Open Player Settings. Under Publishing Settings check the Split Application Binary checkbox. This will create the OBB file.
When deploying the application locally, the OBB file is copied to the correct location automatically. See this page on handling OBB files via the Play Store with Unity.
To switch the video playing without destroying and creating a new TexturePlayer component:
GvrVideoTexturePlayer
script, specifically, the VideoType, VideoURL, VideoContentID and VideoProviderID.TexturePlayer.CleanupVideo()
.TexturePlayer.ReinitializeVideo()
. This will create a new instance of ExoPlayer.Because initializing the player and loading the video stream are asynchronous operations, it can be useful to have a callback when the video is ready. This is an alternative to polling the VideoReady property in the Update method. You can register a callback to be called when the video is ready by invoking GvrVideoTexturePlayer.OnVideoEventCallBack()
.
For example:
Getcomponent<TexturePlayer>().SetOnVideoEventCallback(eventId) => {
Debug.Log("Video is ready!")
UpdateStatusText();
);
The available eventIds are:
When something goes wrong with the video playback, the player throws an exception. A callback can be registered to be invoked when exceptions occur by calling GvrVideoTexturePlayer.SetOnExceptionCallback()
. For example:
GetComponent<TexturePlayer>().SetOnExceptionCallback(
(type, message) => {
Debug.LogError("Exception of type: " + type + ": " + message);
}
);
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["The GVR video plugin utilizes ExoPlayer for streaming flat and 360° videos in mono and stereo formats, supporting adaptive streaming like DASH and HLS for Daydream VR experiences."],["The `GvrVideoPlayerTexture` script renders video onto a Unity texture, enabling placement on any mesh renderer within the scene, and offering customization of properties like buffer size, video type, resolution, and aspect ratio."],["Example scenes demonstrate setting up flat and spherical video playback, requiring configuration of the main camera, video player object with material, and attaching the `GvrVideoPlayerTexture` script with relevant video properties."],["Large video assets can be managed by storing them in an OBB file and adjusting the Video Texture Player properties accordingly to bypass the 100MB APK file size limit."],["Dynamic video switching and handling asynchronous operations are facilitated through callbacks like `OnVideoEvent` (for events like video readiness and format changes) and `OnException` (for error handling)."]]],["The GVR SDK for Unity offers a video plugin for streaming flat and 360° videos in mono and stereo, using the ExoPlayer library. The `GvrVideoPlayerTexture` script configures the video player and renders it onto a Unity texture. Key properties include video type (Dash, HLS, Other), URL, Content/Provider IDs, and resolution. The setup involves creating a scene with Daydream support, importing the GVR and VideoPlayer SDKs. Examples are provided for flat and spherical videos, and large video files can be stored in OBB files. Switching video streams is possible by adjusting properties and calling cleanup and reinitialize methods. Callbacks are available for events like video readiness and exceptions.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4