Log in or register to post comments

Video not pause due to automatic playing

April 10, 2013 - 2:58am #11

 

Hi , I was look to start video automatically as soon the target is detected. I was successful by applying below code.
But now i'm not able to pause video on single tap. I confirmed issue is due to change in code in VideoRenderer.java to play video automatically when target is detected. please help. 

Single tap and onPause functions are working but this code is not allowing to pause the video. I need both the functionalities automatic palying of video when target is detected and pausing video on single tap.


for (int i = 0; i < VideoPlayback.VIDEO_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();
				// }
				// }
			}
		}

 

 

Video not pause due to automatic playing

April 11, 2013 - 12:10am #10

Hi Moderators,

 

Please help me out. Its critical for me.

Video not pause due to automatic playing

April 11, 2013 - 1:07am #9

Hi, when (from which function) are you executing the code below (the one that you pasted) ?

 

Video not pause due to automatic playing

April 11, 2013 - 1:12am #8

Hi , This code exists in draw Frame . This is called after following lines

 

renderFrame();
 

 

Video not pause due to automatic playing

April 11, 2013 - 2:31am #7

Ok, then the issue is that at every single frame you are telling the video to play (in your code) as it is tracked (isTracking is true)

you should probably change it so you say "mVideoPlayerHelper[i].play(false, -1);" only if it has been detected (i.e. only the first time, not at every frame).

 

Video not pause due to automatic playing

April 11, 2013 - 2:47am #6

i think its necessary because i want to play video automatically as soon it detects target.

how should i detect it's first time? 

Video not pause due to automatic playing

April 11, 2013 - 3:07am #5

Just tried with boolean flag and my video gets black.

 

if( is(Tracking(i) and VIDEO_PLAY ==false) 

 

{
if (mVideoPlayerHelper[i] != null)
mVideoPlayerHelper[i].play(false, -1);
 
VIDEO_PLAY = true;
}
else
{}

Video not pause due to automatic playing

April 16, 2013 - 3:18am #4

Video not pause due to automatic playing

April 16, 2013 - 3:29am #3

Great !

Video not pause due to automatic playing

December 12, 2013 - 2:19am #2

Thank you for your code. it save my time :D

Video not pause due to automatic playing

September 30, 2015 - 2:05am #1
VideoPlaybackRenderer.java 
Selected code is working fine for me for going to Full screen sceek position 
 
 
// Call our function to render content
        renderFrame();
        
        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;
                
                //For AUTO pLAY NEXT 2 lines
                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 .1 seconds then pause the player
                    if ((SystemClock.uptimeMillis() - mLostTrackingSince[i]) > 100)
                    {
                        if (mVideoPlayerHelper[i] != null)
                            mVideoPlayerHelper[i].pause();
                       
                      for(int j = 0; j < mVideoPlayerHelper.length; j++)
                      {
                     if (mVideoPlayerHelper[j].getStatus() == MEDIA_STATE.PAUSED)
                     {
                        
                     mVideoPlayerHelper[i].play(true,
                                VideoPlayerHelper.CURRENT_POSITION);
 
                     }
                      }
                    }
                }
            }
        }
Log in or register to post comments