无法使用android.graphic.Movie播放mp4文件?

时间:2019-04-17 13:09:08

标签: android android-drawable

我有一个使用android.graphic.Movie来播放动画gif的方法。

现在,我想使用该方法来播放保存在mp4文件中的动画,但它始终返回null。

这是我的方法:

public void set_gif_src(String gif_path) throws IOException {
    if (gif_path == null && gif_path.isEmpty()) {
        Log.d(TAG, "set_gif_src: gif path not found");
        return;
    } else if (_container_width == 0) {
        _path_gif = gif_path;
        _is_load_waiting = true;
        Log.d(TAG, "set_gif_src: loading delay");
        return;
    }
    Log.d(TAG, "set_gif_src: path = " + gif_path);
    if (gif_path.contains(Supporter.PATTERN_ASSET)) {
        gif_path = gif_path.replace(Supporter.PATTERN_ASSET, "");
        InputStream ips = getContext().getAssets().open(gif_path);
        Log.d(TAG, "set_gif_src: ips = NULL  " + (ips == null));
        _player = Movie.decodeStream(ips);
    } else if (gif_path.contains(Supporter.PATTERN_EXTERNAL_STORAGE)) {
        gif_path = gif_path.replace(Supporter.PATTERN_EXTERNAL_STORAGE, "");
        _player = Movie.decodeFile(gif_path);
    }
    if (_player == null) {
        Log.e(TAG, "set_gif_src: add gif effect failed");
    }
}

0 个答案:

没有答案
相关问题