Log in or register to post comments

Randomize the Videos

October 22, 2012 - 5:43am #1

hi Guys i m using Video Playback Sample  and i want to play Randomized videos.

how can i achieve this functioinality .

any help /suggestion/ comment will be most welocmmed

thank you

Randomize the Videos

October 23, 2012 - 1:03am #6

Hi, do you stop and release the media player of the old video before laoding a new one ?

(see the VideoPlayback sample code mMediaPlayer.stop() and mMediaPlayer.release());

also, you could check in the onError() method (since your class also implements onErrorListener interface) to see if you get any error when you load the second video...



Randomize the Videos

October 23, 2012 - 12:47am #5

also i want to load multiple videos from sdcard rather then assests folder i tried this thing and it worked for 1 single file loading from sdcard successfully but not  the multiple files are loading from sdcard 

i`ve use the following chunck of code to load from Sdcard in Videoplayback Sample




mMediaPlayer.setSurface(new Surface(mSurfaceTexture));
canBeOnTexture = true;
mShouldPlayImmediately = playOnTextureImmediately;

Randomize the Videos

October 23, 2012 - 12:43am #4

I would say check where the mVideoPlayerHelper[i].play() is called in the VideoPlayback sample (see VideoPlayback.java), so that you can use that function (note: you will need to call that Java function from native code, probably from the _renderFrame function, based on trackable detection...)

About how to choose the video randomly, you could just use a random generation function such as rand() in C++ and pick one video out of your array each time, e.g. suppose you have N videos in total, and you have an array of N videos defined in C++ (e.g. you could keep an array of filenames, one for each video):

int random_index = rand() % N;

const char *randomVideo = videos[ random_index ];

That's just an example, of course you can do this in a thousands different ways.


Randomize the Videos

October 22, 2012 - 10:50pm #3

yes i have a set of Videos of  'n' number wher n can be any integer or let restrict it to 10 videos

when ever i detect the marker  a random video should be played

thats what i want to do


Randomize the Videos

October 22, 2012 - 8:02am #2

Hi, can you be more specific ? do you want to play one video randomly each time you detect a Target?

is the video one of a predefined set of videos (e.g. a set of 5 - 10 videos predefined) ?

Log in or register to post comments