Question: I'm trying to use `android.graphics.Movie` to play a GIF file from `/sdcard/download`.

If I put the file in the `drawable` folder in the APK, I can load it using:

```
InputStream istr = context.getResources().openRawResource(R.drawable.animfile);
Movie movie = Movie.decodeStream(istr);

```

That works. `movie.duration()` will show the correct duration, which I use to derive the value for `movie.setTime()`.

The problem happens if, instead of drawable, I try to load it from the sd-card using

```
String path = Environment.getExternalStorageDirectory() + "/download/animfile.gif";
Movie movie = Movie.decodeFile(path);

```

It seems to load *something* as `movie` isn't null. But the problem is that `movie.duration()` returns `0`.

Any idea why this happens, and what I should be doing?

Answer: 
You are right, except a one. You shouldn't use Uri and ContentResolver. Short solution is that you should use

```
Movie.decodeByteArray(array, 0, array.length)

```

instead of 

```
Movie.decodeFile(path);

```

clue is in reset() method implementation of some stream that created inside the decodeFile(path) method.
```
 is = new FileInputStream(file path);

                if (path != null) {
                            try {
                                byte[] array = streamToBytes(is);
                                mMovie =  Movie.decodeByteArray(array, 0, array.length);

                                mDuration = mMovie.duration();
                                Log.v("total time ", mDuration + "");
                            } finally {
                                is.close();
                            }
                        } else {
                            throw new IOException("Unable to open R.raw.");
                        }

 private byte[] streamToBytes(InputStream is) {
                ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
                byte[] buffer = new byte[1024];
                int len;
                try {
                    while ((len = is.read(buffer)) >= 0) {
                        os.write(buffer, 0, len);
                    }
                } catch (java.io.IOException e) {
                }
                return os.toByteArray();
            }

```