Log in or register to post comments

playing youtube video over marker using Imagetarget file

November 12, 2011 - 5:20pm #1

I saw a question and answer posted previously on StackOverflow at this link

http://stackoverflow.com/questions/7187248/marker-based-ar-android-application-using-qualcomm-sdk

I’m trying to do something similar with the QCAR SDK. I am trying to display a YouTube video over the stones image. My base code is the images target file in the samples folder. I followed the steps mentioned here but I still get only the teapot to render over the image. Is there any other change I need to implement in the files?

Re: playing youtube video over marker using Imagetarget file

December 27, 2011 - 12:43pm #14

Follow the Getting Started - SDK guide on the SDK portal: http://ar.qualcomm.com

Step 3 shows you how to compile the shared object using ndk-build. Make sure you've followed all of Step 1 first, including adding the ndk directory to your system path.

- Kim

Re: playing youtube video over marker using Imagetarget file

December 27, 2011 - 12:49am #13

Hi kim,
can you tell me where i can find out how to build the cpp code using ndk?

Thanks.

Re: playing youtube video over marker using Imagetarget file

December 20, 2011 - 9:15pm #12

Make sure you rebuild the native code using ndk-build. Then, refresh your project in Eclipse. Right-click on the project in the Package Explorer and choose Refresh.

- Kim

Re: playing youtube video over marker using Imagetarget file

December 20, 2011 - 4:33pm #11

Hi kim,
I tried changing the renderFrame code to what you told me to.But the teapot is still getting rendered. I don't know what to do.

Thanks,
Sharat

Re: playing youtube video over marker using Imagetarget file

December 19, 2011 - 8:35am #10

The teapot is rendered in the ImageTargets.cpp renderFrame method. You can pull out all the rendering code from that method to distill it down to something like this:

JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *, jobject)
{
    // Clear color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Render video background:
    QCAR::State state = QCAR::Renderer::getInstance().begin();

    // Did we find any trackables this frame?
    for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
    {
        // Get the trackable:
        const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);

        // Do something with the trackable here
    }

    QCAR::Renderer::getInstance().end();
}

- Kim

Re: playing youtube video over marker using Imagetarget file

December 16, 2011 - 8:40pm #9

Thanks Robert.

For some reason i'm not able to get rid of the teapot model. Can you please tell me where i need to remove code to prevent the teapot from apperaing.

And can i instead create a jar file of a videoplayer app having VideoViewDemo class that i created and call this in my intent to play the video. I have to call it in the ImageTargetsRenderer class under playVideo method right?

// Called from native to play a video
    public void playVideo(String trackableName)
    {
//    	Intent intent = new Intent(context,MediaPlayer.class);
    	 Intent intent = new Intent(context,VideoViewDemo.class);
    	
    	context.startActivity(intent);
    }

Re: playing youtube video over marker using Imagetarget file

December 12, 2011 - 4:17am #8

You could just do something like this?


private static final String VIDEO_LOCATION = "/sdcard/media/";
private static final String VIDEO_NAME = "myvideo.mp4";
private static final String VIDEO_FILE_TYPE = "video/mp4";

try {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse(VIDEO_LOCATION+VIDEO_NAME), VIDEO_FILE_TYPE);
    startActivity(intent);
} catch (Exception e){
    Toast.makeText(getBaseContext(), "Video could not be played", 1).show();
}

That'll just send the video data to be played by another app externally.

Re: playing youtube video over marker using Imagetarget file

November 25, 2011 - 6:27pm #7

I have a question in MediaPlayerDemo_Video project. I have tried running it but the emulator crashed and i get the following error message

goldfish_fb_load: framebuffer dimensions mismatch
savevm: unable to load section goldfish_fb

Can you please tell me why i get this error?
Also if i integrate this ti the qcar project, do i need to specify the url path under the case:STREAM_VIDEO?

Thanks
Sharat

Re: playing youtube video over marker using Imagetarget file

November 19, 2011 - 9:38am #6

That code assumes you've started with the Android media player sample. Look through the sample code that comes with the Android SDK. If you've installed the sample code when you installed the Android SDK you should be able to search your system for MediaPlayerDemo_Video to find the right one.

- Kim

Re: playing youtube video over marker using Imagetarget file

November 18, 2011 - 1:46am #5

ok. Can you tell me what's happening here...

Intent intent = new Intent(context,MediaPlayerDemo_Video.class);
intent.putExtra(MEDIA,LOCAL_VIDEO);
context.startActivity(intent);

Do i need to create a MediaPlayerDemo_video class? and what do i have to store in MEDIA and LOCAL_VIDEO?
Now for playing a video from youtube, will this work or do i have to follow the steps given in the stackoverflow link that i mentioned

Re: playing youtube video over marker using Imagetarget file

November 15, 2011 - 9:21am #4

You need to make changes to ImageTargets.cpp as well. Take a look at this post again:

http://ar.qualcomm.at/node/2001096

Someone needs to call playVideo!

You can remove the teapot rendering code from the renderFrame method in that file as well.

- Kim

Re: playing youtube video over marker using Imagetarget file

November 14, 2011 - 11:33am #3

Thanks kim.
I tried making changes to the code

ImageTargetsRenderer.java

public static Context context;
public void playVideo(String trackableName)
{
// Intent intent = new Intent(context,MediaPlayerDemo_Video.class);
// intent.putExtra(MEDIA,LOCAL_VIDEO);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.youtube.com/watch?v=66TuSJo4dZM"));
// startActivity(intent);
context.startActivity(intent);
}

ImageTargets.java

protected void onResume()
{
DebugLog.LOGD("ImageTargets:: onResume");
super.onResume();
ImageTargetsRenderer.context = this;
// ImageTargetsRenderer.mainActivityHandler = new Handler() {
// @Override
// public void handleMessage(Message msg) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse("http://www.youtube.com/watch?v=66TuSJo4dZM"));
// startActivity(intent);
// ImageTargets.this.finish();
// }
// };
// QCAR-specific resume operation
QCAR.onResume();

// We may start the camera only if the QCAR SDK has already been
// initialized
if (mAppStatus == APPSTATUS_CAMERA_STOPPED)
updateApplicationStatus(APPSTATUS_CAMERA_RUNNING);

// Resume the GL view:
// if (mGlView != null)
// {
// mGlView.setVisibility(View.VISIBLE);
// mGlView.onResume();
// }
}

Is this code ok?

i'm still getting the teapots on the marker.
How to disable the teapot rendering.

Note: Apart from the changes in ImageTargets.java , ImageTargetsRender.java and ImageTargets.cpp i haven't made any other changes to the ImageTargets sample project

Re: playing youtube video over marker using Imagetarget file

November 12, 2011 - 9:24pm #2

You should find some code in this thread that will help:

http://ar.qualcomm.at/node/2001096

Note that both this and the StackOverflow thread are talking about playing a fullscreen video in 2D, not video overlaid on the target plane in 3D.

- Kim

Log in or register to post comments