Log in or register to post comments

How To Stop Video on Button Click (VideoPlayBack)

March 18, 2013 - 2:37am #1

Hi,

I am working on video playback sample,i have created one view controller with button to open camera

and close button in VPParentViewController onclick of that button i am stoping camera,

but  my videos are still  playing in background how to stop video on button press.

How To Stop Video on Button Click (VideoPlayBack)

November 19, 2013 - 9:44pm #3

For those who has the same problem as @Snehal12This might help you out.

Got it working by stopping all of the instances of the VideoPlayerHelper before dismissing the view.

- (void)dismiss 
{ 
    EAGLView* arView = [self getARView];
    for (int i = 0; i < NUM_VIDEO_TARGETS; ++i) {
        VideoPlayerHelper* player = [arView getVideoPlayerHelper:i];
        [player stop];
    }
    [self dismissViewControllerAnimated:NO completion:nil];
 }

 

How To Stop Video on Button Click (VideoPlayBack)

March 18, 2013 - 6:13am #2

If you are reconfiguring the code to run in your own ViewControllers, you need to make sure that all existing functionality gets called.  If not, then you may see strange behaviour.

If you look in VideoPlayerHelper.m you will see the method below.

Check that this is being called in order to top the video playback.

 

HTH

N

 

 

// Stop playback (on-texture player only)

- (BOOL)stop

{

    BOOL ret = NO;

    

    // Control available only when playing on texture (not the native player)

    if (PLAYING == mediaState) {

        if (PLAYER_TYPE_ON_TEXTURE == playerType) {

            [dataLock lock];

            mediaState = STOPPED;

            

            // Stop the audio (if there is any)

            if (YES == playAudio) {

                [player pause];

            }

            

            // Stop the frame pump thread

            [self waitForFrameTimerThreadToEnd];

            

            // Reset the playback cursor position

            [self updatePlayerCursorPosition:PLAYER_CURSOR_POSITION_MEDIA_START];

            

            [dataLock unlock];

            ret = YES;

        }

        else {

            NSLog(@"Stop control available only when playing video on texture");

        }

    }

    

    return ret;

}

 

 

 

Log in or register to post comments