Hi,
I am using a SurfaceView and a Thread to draw animated gif on a canvas
and its working perfectly.
Once I try to draw my second animated gif, I'm getting 2 animated
gifs
with the last animinated gif aniation.
like my second Movie.DecodeStream(is) override the first Movie.


The result of the code below is  2 animated gif with movie2 animation
Please advise what can be the problem.
Thanks in advance


code:

Thread constructor:
InputStream is
is = mRes.openRawResource(R.drawable.animated_gif1);
Movie movie1 = Movie.decodeStream(is);
try {
         is.close();
      } catch (java.io.IOException e) {
                     /*  do nothing.
                         If the exception happened on open, moov will
be null.
                         If it happened on close, moov is still valid.
                  */
      }

is = mRes.openRawResource(R.drawable.animated_gif2);
Movie movie2 = Movie.decodeStream(is);
try {
         is.close();
      } catch (java.io.IOException e) {
                     /*  do nothing.
                         If the exception happened on open, moov will
be null.
                         If it happened on close, moov is still valid.
                  */
      }
....
....
....

doDraw(Canvas c) {
....

long now = android.os.SystemClock.uptimeMillis();
                    if (mMovieStart == 0) {   // first time
                        mMovieStart = now;
                    }

int dur = movie1.duration();
if (dur == 0)
      dur = 1000;

int relTime = (int)((now - mMovieStart) % dur);
movie1.setTime(relTime);
movie1.draw(canvas, 100, 100);

int dur = movie2.duration();
if (dur == 0)
      dur = 1000;

relTime = (int)((now - mMovieStart) % dur);
movie2.setTime(relTime);
movie2.draw(canvas, 100, 100);

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to