- Sort Posts
- 5 replies
- Last post
play youtube video
play youtube video
Youtube video URLs usually do not point explicitely to a video file (such as ".mp4" or ".m4v" files), i.e. the URL itself does not contain a path to a video file;
the video playback sample requires you to have an explicit video file path in the URL,
see:
https://developer.vuforia.com/forum/faq/videoplayback-what-videos-can-i-play-what-platform
play youtube video
Note that a developer has shared an approach using some library called YouTubeAndroidPlayerApi available at https://developers.google.com/youtube/android/player/
in this thread here:
play youtube video
In class VideoPlayBack there is a method onSingleTapConfirmed
put this code inside it and enjoy youtube or any link......
{
boolean isSingleTapHandled = false;
// Do not react if the StartupScreen is being displayed
for (int i = 0; i < NUM_TARGETS; i++)
{
// Verify that the tap happened inside the target
if (mRenderer!= null && mRenderer.isTapOnScreenInsideTarget(i, e.getX(),
e.getY()))
{
if (i == 0)
{
Intent intra = new Intent(Intent.ACTION_VIEW);
intra.setData(Uri.parse("put ljnk here"));
startActivity(intra);
}
}
if (i == 1)
{
Intent intr = new Intent(Intent.ACTION_VIEW);
intr.setData(Uri.parse("put ljnk here"));
startActivity(intr);
}
if (i == 2)
{
Intent intr1 = new Intent(Intent.ACTION_VIEW);
intr1.setData(Uri.parse("https://yput ljnk here"));"));
startActivity(intr1);
}
//------ FUllScreen remove.... just uncomment the below code
// Check if it is playable on texture
/* if (mVideoPlayerHelper[i].isPlayableOnTexture())
{
// We can play only if the movie was paused, ready
// or stopped
if ((mVideoPlayerHelper[i].getStatus() == MEDIA_STATE.PAUSED)
|| (mVideoPlayerHelper[i].getStatus() == MEDIA_STATE.READY)
|| (mVideoPlayerHelper[i].getStatus() == MEDIA_STATE.STOPPED)
|| (mVideoPlayerHelper[i].getStatus() == MEDIA_STATE.REACHED_END))
{
// Pause all other media
pauseAll(i);
// If it has reached the end then rewind
if ((mVideoPlayerHelper[i].getStatus() == MEDIA_STATE.REACHED_END))
mSeekPosition[i] = 0;
mVideoPlayerHelper[i].play(mPlayFullscreenVideo,
mSeekPosition[i]);
mSeekPosition[i] = VideoPlayerHelper.CURRENT_POSITION;
} else if (mVideoPlayerHelper[i].getStatus() == MEDIA_STATE.PLAYING)
{
// If it is playing then we pause it
mVideoPlayerHelper[i].pause();
}
} else*/ if (mVideoPlayerHelper[i].isPlayableFullscreen())
{
// If it isn't playable on texture
// Either because it wasn't requested or because it
// isn't supported then request playback fullscreen.
mVideoPlayerHelper[i].play(true,
VideoPlayerHelper.CURRENT_POSITION);
}
isSingleTapHandled = true;
// Even though multiple videos can be loaded only one
// can be playing at any point in time. This break
// prevents that, say, overlapping videos trigger
// simultaneously playback.
break;
}
}
return isSingleTapHandled;
}
Search the forums, as this has been asked before.
Basically you can't really do this because the sample plays back remote video files from a web server that enforces the live stream video protocol for video files. Youtube does not do this, but you can set your own one up. However this is outside the scope of forum support.
N