{"_id":"5ad78c382cfba50003554c4e","category":{"_id":"5ad78c362cfba50003554bfe","version":"5ad78c362cfba50003554bfc","project":"5a065a6134873d0010b396ab","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-18T21:08:45.730Z","from_sync":false,"order":1,"slug":"develop","title":"Develop"},"project":"5a065a6134873d0010b396ab","parentDoc":null,"user":"578c4a62bd223d2000cc143e","version":{"_id":"5ad78c362cfba50003554bfc","project":"5a065a6134873d0010b396ab","__v":1,"createdAt":"2018-04-18T18:19:34.288Z","releaseDate":"2018-04-18T18:19:34.288Z","categories":["5ad78c362cfba50003554bfd","5ad78c362cfba50003554bfe","5ad78c362cfba50003554bff","5ad78c362cfba50003554c00"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.6.0","version":"1.6.0"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-18T18:29:46.178Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":22,"body":"Viro supports various components for displaying video. Video can be displayed in 360 degrees, surrounding the user, or on a flat plane, simulating a physical video screen.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Video Texture\"\n}\n[/block]\nThe [VideoTexture](https://developer.viromedia.com/virocore/reference/com/viro/core/VideoTexture.html) object is used to render video. Because this extends Texture, it can be assigned to any Material, and from any Material to any Geometry and Node. In the example below, a VideoTexture is loaded onto a Surface, simulating a video screen.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"VideoTexture videoTexture = new VideoTexture(context, uri);\\nMaterial material = new Material();\\nmaterial.setDiffuseTexture(videoTexture);\\n\\nSurface surface = new Surface(10, 10);\\nsurface.setMaterials(Arrays.asList(material));\\n\\nvideoTexture.play();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nSupported video formats are .mov, .mp4, .mpv, and .3gp. The video source may be a remote URL or a local file resource. To invoke with a remote URL, set the source to a URI. For example, `Uri.parse(\"http://example.org/myvideo.mp4\")`. To load an asset as video, use URI's of the form `file:///android_asset/[asset-name]`.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"360 Video\"\n}\n[/block]\nSpherical videos that surround the user can be displayed via VideoTexture as well. To do this, simply assign the VideoTexture to the Scene's background, as shown below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"VideoTexture videoTexture = new VideoTexture(context, uri);\\nscene.setBackgroundTexture(videoTexture);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Manipulating Video\"\n}\n[/block]\nVideoTexture also controls the playback of the video. You can:\n* Adjust volume via the ```volume``` property\n* Mute the video via the ```muted``` property\n* Make the video loop by setting the ```loop``` property\n* Pause and play the video\n* Seek the video to a specific time in seconds by invoking the ```seekToTime(float)``` method\n\nYou can also respond to various playback events by implementing a [PlaybackListener](https://developer.viromedia.com/virocore/reference/com/viro/core/VideoTexture.PlaybackListener.html).","excerpt":"Adding video to your scenes","slug":"video","type":"basic","title":"Video"}

Video

Adding video to your scenes

Viro supports various components for displaying video. Video can be displayed in 360 degrees, surrounding the user, or on a flat plane, simulating a physical video screen. [block:api-header] { "type": "basic", "title": "Video Texture" } [/block] The [VideoTexture](https://developer.viromedia.com/virocore/reference/com/viro/core/VideoTexture.html) object is used to render video. Because this extends Texture, it can be assigned to any Material, and from any Material to any Geometry and Node. In the example below, a VideoTexture is loaded onto a Surface, simulating a video screen. [block:code] { "codes": [ { "code": "VideoTexture videoTexture = new VideoTexture(context, uri);\nMaterial material = new Material();\nmaterial.setDiffuseTexture(videoTexture);\n\nSurface surface = new Surface(10, 10);\nsurface.setMaterials(Arrays.asList(material));\n\nvideoTexture.play();", "language": "java" } ] } [/block] Supported video formats are .mov, .mp4, .mpv, and .3gp. The video source may be a remote URL or a local file resource. To invoke with a remote URL, set the source to a URI. For example, `Uri.parse("http://example.org/myvideo.mp4")`. To load an asset as video, use URI's of the form `file:///android_asset/[asset-name]`. [block:api-header] { "type": "basic", "title": "360 Video" } [/block] Spherical videos that surround the user can be displayed via VideoTexture as well. To do this, simply assign the VideoTexture to the Scene's background, as shown below. [block:code] { "codes": [ { "code": "VideoTexture videoTexture = new VideoTexture(context, uri);\nscene.setBackgroundTexture(videoTexture);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Manipulating Video" } [/block] VideoTexture also controls the playback of the video. You can: * Adjust volume via the ```volume``` property * Mute the video via the ```muted``` property * Make the video loop by setting the ```loop``` property * Pause and play the video * Seek the video to a specific time in seconds by invoking the ```seekToTime(float)``` method You can also respond to various playback events by implementing a [PlaybackListener](https://developer.viromedia.com/virocore/reference/com/viro/core/VideoTexture.PlaybackListener.html).