如何使用youtube播放器活动在vuforia videoplayback app中使用url播放视频

时间:2014-04-19 12:21:32

标签: sample vuforia

我正在使用Vuforia sdk进行AR项目并关注VideoPlayBack示例项目,我只想使用youtube url播放视频。所以我添加了一个youtube播放器活动类项目并将静态videoid传递给它正常工作的活动。 ....但问题是我删除了以前在assests文件夹中显示的视频然后应用程序崩溃。

如何在Vuforia示例应用程序中停止加载videoplayerhelper类:

protected void onCreate(Bundle savedInstanceState)
    {
        Log.d(LOGTAG, "onCreate");
        super.onCreate(savedInstanceState);

    vuforiaAppSession = new SampleApplicationSession(this);

    mActivity = this;

    startLoadingAnimation();

    vuforiaAppSession
        .initAR(this, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Load any sample specific textures:
    mTextures = new Vector<Texture>();
    loadTextures();

    // Create the gesture detector that will handle the single and
    // double taps:
    mSimpleListener = new SimpleOnGestureListener();
    mGestureDetector = new GestureDetector(getApplicationContext(),
        mSimpleListener);

    mVideoPlayerHelper = new VideoPlayerHelper[NUM_TARGETS];
    mSeekPosition = new int[NUM_TARGETS];
    mWasPlaying = new boolean[NUM_TARGETS];
    mMovieName = new String[NUM_TARGETS];

    // Create the video player helper that handles the playback of the movie
    // for the targets:
    for (int i = 0; i < NUM_TARGETS; i++)
    {
        mVideoPlayerHelper[i] = new VideoPlayerHelper();
        mVideoPlayerHelper[i].init();
        mVideoPlayerHelper[i].setActivity(this);
    }

    mMovieName[STONES] = "VideoPlayback/VuforiaSizzleReel_1.mp4";
    mMovieName[CHIPS] = "VideoPlayback/VuforiaSizzleReel_2.mp4";

    // Set the double tap listener:
    mGestureDetector.setOnDoubleTapListener(new OnDoubleTapListener()
    {
        // Handle the double tap
        public boolean onDoubleTap(MotionEvent e)
        {
            boolean isDoubleTapHandled = false;
            for (int i = 0; i < NUM_TARGETS; i++)
            {
                // Verify that the tap happens inside the target:
                if (mRenderer!= null && mRenderer.isTapOnScreenInsideTarget(i, e.getX(),
                    e.getY()))
                {
                    // Check whether we can play full screen at all:
                 if (mVideoPlayerHelper[i].isPlayableFullscreen())
                    {
                        // Pause all other media:
                        pauseAll(i);

                        // Request the playback in fullscreen:
                        mVideoPlayerHelper[i].play(true,
                            VideoPlayerHelper.CURRENT_POSITION);

                        isDoubleTapHandled = 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 isDoubleTapHandled;
        }


        public boolean onDoubleTapEvent(MotionEvent e)
        {
            // We do not react to this event
            return false;
        }


        // Handle the single tap
        public boolean onSingleTapConfirmed(MotionEvent e)
        {
            boolean isSingleTapHandled = false;
           /// Toast.makeText(getApplicationContext(), "single touch", Toast.LENGTH_LONG).show();
            // 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()))
                {

                    Intent intent=new Intent(VideoPlayback.this,VideoActivity.class);
                    intent.putExtra("videoid", "yCt-YUbs7H4");
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    startActivity(intent);
                    isSingleTapHandled = true;
                    break;
                }
            }
            return isSingleTapHandled;
        }
    });
}

0 个答案:

没有答案