I have implemented Gif movie player using https://github.com/sbakhtiarov/gif-movie-view, it's working good but I want pause Gif image when first start activity, that means first open activity, I tried gif1.setPaused(true); but it's not working so how can i solve it? Please guys help to solve it!!!
Asked
Active
Viewed 89 times
2 Answers
1
I solve it using onDraw method, Just change
@Override
protected void onDraw(Canvas canvas) {
//for infinitive time animate
/*if (mMovie != null) {
if (!mPaused) {
updateAnimationTime();
drawMovieFrame(canvas);
invalidateView();
} else {
drawMovieFrame(canvas);
}
}*/
//for one time animate
final long now = SystemClock.uptimeMillis();
if (mMovieStart == 0) {
mMovieStart = (int) now;
}
if (mMovie != null) {
if (!mPaused) {
int relTime = (int) (now - mMovieStart);
if (relTime > mMovie.duration()) {
relTime = mMovie.duration();
}
mMovie.setTime(relTime);
mMovie.draw(canvas,
getWidth() / 2 - mMovie.width() / 2,
getHeight() / 2 - mMovie.height() / 2);
if (relTime < mMovie.duration()) {
invalidate();
}
} else {
drawMovieFrame(canvas);
}
}
}
And put in MainActivity
gif1.setMovieResource(R.drawable.earth_tilt_animation);
gif1.setPaused(!gif1.isPaused());
0
Try this
gif.setPaused(!gif.isPaused());
Because there is no code in library for gif1.setPaused(true);
Just check in GifMovieView.java
public void setPaused(boolean paused) {
this.mPaused = paused;
/**
* Calculate new movie start time, so that it resumes from the same
* frame.
*/
if (!paused) {
mMovieStart = android.os.SystemClock.uptimeMillis() - mCurrentAnimationTime;
}
invalidate();
}
Try to make one function in GifMovieView.java
public void stop() {
mMovie.stop;
invalidate();
}
I m not sure it works but hope it will work.

Chirag Ghori
- 4,231
- 2
- 20
- 35
-
Any another idea about How to stop player at the starting? – May 26 '16 at 14:17
-
It like `setPaused` method is for restart gif not for stop.. wait i will see if anything i got !! – Chirag Ghori May 26 '16 at 14:18
-
mMovieStart not contain stop method, Please have you another idea? – May 26 '16 at 14:25
-
I have no idea now but if i got something then i will update here – Chirag Ghori May 26 '16 at 14:30
-
Try `mMovie.stop;` Instead of `mMovieStart.stop;` – Chirag Ghori May 26 '16 at 14:34
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/113098/discussion-between-komal-and-chirag-ghori). – May 27 '16 at 04:11