Log in or register to post comments

How to play youtube vedios instead of assets folder vedios using vedioplayback sample app in android

April 15, 2013 - 2:32am #1

 

Hi am working on augumented reality in android,using augumented reality sample app,vedioplayback i can able to play two different vedios for two different target images like

for chips image---- sound1

for stones image---sound2

here sound1 and sound2  i gave using assets folder,

like that,but  my requirement is instead of sound1 and sound2 i have to give youtobe vedios.

ex:

 

for chips image---- "http://www.youtube.com/watch?v=pAX8R6UH8CY"

for stones image---"http://www.youtube.com/watch?v=-tAH1hW_tYc"

like that i have to give.....how to play youtube vedios using vedioplayback sample app in android augumented reality...please any one help me..

How to play youtube vedios instead of assets folder vedios using vedioplayback sample app in android

March 29, 2019 - 2:37am #10

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;

            }

How to play youtube vedios instead of assets folder vedios using

September 28, 2014 - 1:14pm #9

I've done this successfully. You need to use the YouTubeAndroidPlayerApi available at https://developers.google.com/youtube/android/player/

Note, I am forcing fullscreen in my app - you'll probably have to use that model as well for Youtube, as I dont think you'd be able to access the texture properly/fast enough to map it to the targetbounds... 

This is in VideoPlayerHelper load() method - i ask the user if they want to download the content through the sync or stream from youtube, so save that to Shared Preferences, so you can see that I ask what the user has chosen... 

            if ((requestedType == MEDIA_TYPE.FULLSCREEN) || (requestedType == MEDIA_TYPE.ON_TEXTURE_FULLSCREEN))

            {

            //check if user wants to stream

            if(mParentActivity.getApplicationContext().getSharedPreferences("com.theonlyanimal.secondstory", Context.MODE_PRIVATE).getBoolean("com.theonlyanimal.secondstory.stream", false)){

            //lets start youtube video

            mPlayerHelperActivityIntent = new Intent(mParentActivity, FullscreenYoutubePlayback.class);

            }

            else {

            //if downloaded check if videos already downloaded

            if(Constants.downloadedAllVideos){

            //show from storage

            mPlayerHelperActivityIntent = new Intent(mParentActivity, FullscreenPlayback.class);

            }

            else{

            //if not yet downloaded show from youtube

            mPlayerHelperActivityIntent = new Intent(mParentActivity, FullscreenYoutubePlayback.class);

            }

            

            }

            mPlayerHelperActivityIntent.setAction(android.content.Intent.ACTION_VIEW);

                canBeFullscreen = true;

            }

 

Then,  this is my new class... 

https://github.com/JesseScott/SecondStory-Android/blob/master/SecondStory/src/com/theonlyanimal/ar/FullscreenYoutubePlayback.java

 

How to play youtube vedios instead of assets folder vedios using

September 27, 2014 - 9:08am #8

I guess one possibiility might be to use some 3rd party tools or libraries that allow obtaining and downloading the video file out of the youtube URL, so to download (for example) the video file to the device storage and then play it from there. However I cannot recommend any such tools or library (if anyone knows some, feel free to share).

 

How to play youtube vedios instead of assets folder vedios using

April 15, 2013 - 5:08am #7

okey thankyou.anyone  having any idea about playing youtube vedios in vedioplayback let me

How to play youtube vedios instead of assets folder vedios using

April 15, 2013 - 5:04am #6

Hi, thanks for sharing the Android code;

unfortunately, that coe simply asks the system (Android) to open a web browser with the video URL; this will play the video, but it will be embedded in a web browser; with that approach, there is no direct way to get the content programmatically and integrate it in the VP sample.

 

 

How to play youtube vedios instead of assets folder vedios using

April 15, 2013 - 4:48am #5

ok.using android sdk we can play youtube vedios using below code

 

Intent webIn = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://www.youtube.com/watch?v=uFghjFCM82E"));
    startActivity(webIn);
but in vedioplayback how we can play youtube vedios for different target iamges

How to play youtube vedios instead of assets folder vedios using

April 15, 2013 - 4:21am #4

Correct. You cannot.

However, you might search on Android web forums for alternative approaches on how to play youtube videos using the Android SDK, and perhaps you could find some solution that you could be able to integrate in the VideoPlayback sample.

(If you find such solution, please feel mfree to share it with us, as many other people are interested i the same topic)

 

How to play youtube vedios instead of assets folder vedios using

April 15, 2013 - 4:14am #3

ok.tnnx.so i cant play youtubevedio in vedioplayback example?

How to play youtube vedios instead of assets folder vedios using

April 15, 2013 - 3:43am #2

Hi, Youtube videos cannot be played with the Videoplayback sample, because this relies on the Android MediaPlayer, which can play videos from URLs which point to actual video files;

the Youtube URLs do not actually point to a video file;

the same topic is addressed here:

https://developer.vuforia.com/forum/ios/how-play-video-youtube-using-videoplayback

 

Log in or register to post comments