按照原作者的想法,是可以实现手机观察到播放封面,但没法点击播放。针对这个问题,我翻看了官方论坛,因为最新的unity包缺少了一个C#文件。把缺少的文件加上,可以实现播放,以下为详细说明:
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工程
- 引入Vuforia video playback的unity包
- 创建一个新的场景
- 拖ARCamera进场景(ARCamera搜索下很好找到)
- 点击场景中的ARCamera,右边Inspector栏目,DataSetLoadBehaviour(script)中“Load Data Set StonesAndChips”和 'Activate'都打上勾
- 从'/Qualcomm AugmentedReality/Prefabs'目录中Image Target拖入场景,右边Data Set选择“StonesAndChips”
- 从“Vuforia Video Playback/Prefabs”目录中Video拖入场景,右边“Video Playback Behaviour (Script)”中path栏输入'VuforiaSizzleReel_1.m4v'(测试是播放这个视频),或者也可以使用
这个网络视频进行测试http://oneshot.qualcomm.com/webAR/content/strawberryfields_H264_AAC.mp4
- 把TrackableEventHandler这个C#文件放到Image Target中,主要是用来播放视频的
- 从Image Target中移除DefaultTrackableEventHandler这个文件的使用,因为这个文件根本不需要,移除的话其实把它的打勾去掉也可以
- 自动播放要不要打