- Sort Posts
- 7 replies
- Last post
VideoPlayback sample, running the video's automatically
Following this guy: https://developer.vuforia.com/forum/android/video-not-pause-due-automatic-playing&sort=2
And you can make it auto play.
VideoPlayback sample, running the video's automatically
VideoPlayback sample, running the video's automatically
Was able to achieve the effect finally
In the VideoPlayBackRendere.java File, we already had a hint
// If you would like the video to start playing as soon as it starts tracking
// and pause as soon as tracking is lost you can do that here by commenting
// the for-loop above and instead checking whether the isTracking() value has
// changed since the last frame. Notice that you need to be careful not to
// trigger automatic playback for fullscreen since that will be inconvenient
// for your users.
So this worked
for (int i = 0; i < VideoPlayback.NUM_TARGETS; i++)
{
// Ask whether the target is currently being tracked and if so react to it
if (isTracking(i))
{
// If it is tracking reset the timestamp for lost tracking
// mLostTrackingSince[i] = -1;
if (mVideoPlayerHelper[i] != null)
mVideoPlayerHelper[i].play(false, -1);
}
else
{
// If it isn't tracking
// check whether it just lost it or if it's been a while
// if (mLostTrackingSince[i] < 0)
// mLostTrackingSince[i] = SystemClock.uptimeMillis();
// else
// {
// If it's been more than 2 seconds then pause the player
// if ((SystemClock.uptimeMillis()-mLostTrackingSince[i]) > 2000)
// {
if (mVideoPlayerHelper[i] != null)
mVideoPlayerHelper[i].pause();
// }
// }
}
}
VideoPlayback sample, running the video's automatically
Hi David, Thanks for the quick reply.
I am not able to make the autoplay work by removing mShouldPlayImmediately flag or stting by default true. I could see the flag was used only at
public void onPrepared(MediaPlayer mediaplayer)
{
mCurrentState = MEDIA_STATE.READY;
// If requested an immediate play
//if (mShouldPlayImmediately)
play(false, mSeekPosition);
mSeekPosition = 0;
}
I commented out the code for the checking of mShouldPlayImmediately flag, but still the video gets played only after tapping the screen.
VideoPlayback sample, running the video's automatically
The Auto Play behavior is defined using the mShouldPlayImmediately boolean in the VideoPlayerHelper , see line 57 for the default.
For maximum compatibility across platforms we recommend to use H.264 for video encoding, AAC for audio encoding
and that everything should be packaged on an MPEG-4-like wrapper.
We have found that ".m4v" works well on iOS, Android and Unity while
".MP4" for some reason needs to be re-encoded when imported on Unity.
Things that the developers should stay away from: H.263, AVI, WMV, MKV.
You can remove that element from the Hierarchy in Unity to stop it from displaying.
Thanks,
Vuforia Support