- Sort Posts
- 4 replies
- Last post
Can Virtual Buttons load Video ?
February 27, 2013 - 12:36am #2
Hi, you can combine the scripts of the VideoPlayback sample with the ones of the VirtualButtons samples, it does not really matter which sample you start from;
however, the way I would do it is probably by starting with the VirtualButtons sample and do the following:
- copy the Prefabs from the VideoPlayback sample
- attach a "video object (using a video perfab) to your image target
- Create a script that implements the IVirtualButtonEventHandler interface and register it as a handler for a virtual button
- in particular, implement the OnButtonPressed and/or OnButtonReleased so to start a video when the virtual button is "pressed" or "released"
- in the OnButtonPressed (or OnButtonReleased if you prefer), put the code to play the video; for instance, if you want to play the video fullscreen you could end up with some code similar to the following (this is inspired by the code in VideoPlaybackController.cs):
void OnButtonPressed() { if (video != null) { if (video.VideoPlayer.IsPlayableFullscreen()) { // Pause the video if it is currently playing video.VideoPlayer.Pause(); // Seek the video to the beginning(); video.VideoPlayer.SeekTo(0.0f); // Display the busy icon video.ShowBusyIcon(); // Play the video full screen video.VideoPlayer.Play(true, 0); mWentToFullScreen = true; } } }
You can have a look at the VideoPlaybackController.cs script for inspiration, however you probably don't need that script; you rather need to extract the relevant code (like the one that I have shown above) and copy it into your VirtualButtonEventHandler class, with some little adaptations.
I hope this helps.
I want to play a video when the virtual button is pressed. But I can make it happen. No luck. Anyone can help me to solve my problem? Just send me an email at
thanks,
regards
rezhahino