You are on page 1of 4

The objective here is to show how to replicate the essence of the

Vuforia-VideoPlayback sample scene using the Vuforia prefabs and the


drag and drop approach of Unity:

Create a new Unity project

Import the Vuforia video playback unity package

Create a new scene

Drag the ARCamera prefab into the Unity scene

Under the DataSetLoadBehaviour in the Inspector tick Load Data Set


StonesAndChips, and the 'Activate' checkbox below this
From '/Qualcomm AugmentedReality/Prefabs' drag the ImageTarget

prefab into the scene

For the Image Target select StonesAndChips as the dataset and


the Image Target should change to the Stones texture
From Vuforia Video Playback/Prefabs drag the Video prefab to be the

child of the Image Target

In the Inspector under Video Playback Behaviour (Script) set the


path to 'VuforiaSizzleReel_1.m4v'

Drag the TrackableEventHandler from Scripts to the Image Target (this


plays the video)

Remove the DefaultTrackableEventHandler script from the Image Target


as it is not needed.

Autoplay works already, however tapping the video does not yet work. In
order to fix this, simply create a VideoPlaybackController script, fill it with the
code below, and then attach this to the ARCamera.

Unity - How do I play video from URL ?


December 20, 2013 - 4:47am #1

The Vuforia VideoPlayback sample demonstrates how to play videos


and to render them as an augmentation of your image targets (video
on texture).
The samples use video files that are stored in the assets directory.
However, it is also possible to play videos that are streamed from a
URL (e.g. from the internet).
In the Unity sample, you can achieve this by:

selecting the one of the Image Targets in the Hierarchy view (in the Unity
Editor) and explanding it to show the Video game object underneath (i.e. the
child of the image target )

selecting the Video gameobject and change the Path variable in the
Inspector view (under theVideoPlaybackBehaviour component), replacing
the existing filename (e.g. VuforiaSizzleReel_1.m4v) with the URL of the
video you want to play (e.g. http://my.org.com/my_videos/my_video.mp4).

Build and deploy the udated sample to your device

Note that some video URLs may not work; in particular,

the Web Server you

are connecting to must conforms to the http Live Streaming protocol; also, the URL must point
to an actual video file (such as .mp4 or .m4v). Note: Youtube URLs generally do not work "as is"
with the VP sample, as they don't point explicitly to a video file.
To test this functionality, you can use this sample video:
http://oneshot.qualcomm.com/webAR/content/strawberryfields_H264_AAC.mp4

Also note that there may be certain limitations depending on the


specific OS (Android/iOS) and OS version you are using; please check
this link:

VideoPlayback - What videos can I play on what platform ?


March 10, 2013 - 5:13am #1

The Vuforia VideoPlayback sample is available for Android, iOS and


Unity. However, depending on the specific platform used, certain
restrictions may apply.

Android (native)
Videos can be played on-texture (i.e. video is rendered as a texture
attached to the trackable in 3D space) on devices running Android
4.0 (ICS) and above.
On Android versions prior to 4.0 (i.e. on all 2.x and 3.X versions),
videos can only be played infullscreen mode; the sample code
already contains logic to automatically detect the Android version and
to select fullscreen automatically if needed
Videos can can also be streamed from a network URL (e.g.
"http://myorg/myvideos/video.m4v"); on Android 4.0 and above, videos
streamed from network can be played on-texture without problems or
limitations (same as for local video files).
For a list of supported video/audio file formats on Android, you can
consult this page:
http://developer.android.com/guide/appendix/media-formats.html

iOS (native)
Videos can be played on-texture on any iOS version supported by
Vuforia (no specific limitations).

However, videos that are streamed from a network URL can only be
played in fullscreen mode on iOS.
For a list of supported video/audio file formats on iOS, you can consult
this page:
http://developer.apple.com/library/ios/#documentation/miscellaneo
us/conceptual/iphoneostechoverview/MediaLayer/MediaLayer.htm
l

Unity
In general, the same constraints as for Android or iOS apply,
depending on the target build platform chosen.
In addition, the fullscreen mode (as implemented in the sample) makes
use of a specific API (Handheld.PlayFullscreenMovie) which is only
available with the Unity PRO license (notavailable on Unity Android
Basic / iOS Basic licenses).

You might also like