Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android MediaPlayer抛出错误(1,22),无法播放媒体_Android_Android Mediaplayer - Fatal编程技术网

Android MediaPlayer抛出错误(1,22),无法播放媒体

Android MediaPlayer抛出错误(1,22),无法播放媒体,android,android-mediaplayer,Android,Android Mediaplayer,我正在做一个教程屏幕,在一个viewPager中有几个视频,问题是在三星Galaxy中 07-22 18:24:18.787:E/MediaPlayer(11724):错误(1,-22) 07-22 18:24:18.787:E/com.unipagos.app.tutorial.tutorialPage适配器$1$2@41bbce88(11724):无法播放媒体 我用来播放视频的代码以及在其他设备中使用的代码如下: public void onSurfaceTextureAvailable(S

我正在做一个教程屏幕,在一个viewPager中有几个视频,问题是在三星Galaxy中

07-22 18:24:18.787:E/MediaPlayer(11724):错误(1,-22) 07-22 18:24:18.787:E/com.unipagos.app.tutorial.tutorialPage适配器$1$2@41bbce88(11724):无法播放媒体

我用来播放视频的代码以及在其他设备中使用的代码如下:

public void onSurfaceTextureAvailable(SurfaceTexture surface,
    int width, int height) {
// TODO Auto-generated method stub
Surface s = new Surface(surface);
mMediaPlayer = new MediaPlayer();
mediaPlayers.put(new Integer(position), mMediaPlayer);
try {
    String path = "tutorialvideos/" + tutorialPageItem.getMediaURL();
    AssetFileDescriptor afd = context.getAssets().openFd(path);
mMediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
    mMediaPlayer.setSurface(s);
    mMediaPlayer.setLooping(true);
    mMediaPlayer.setOnPreparedListener(new OnPreparedListener() {

        private int videoPosition;

        public void onPrepared(MediaPlayer mediaPlayer) {
            // close the progress bar and play the video
            //if we have a position on savedInstanceState, the video playback should start from here
            mediaPlayer.seekTo(videoPosition);
            if (videoPosition == 0) {
                mediaPlayer.start();
            } else {
                //if we come from a resumed activity, video playback will be paused
                mediaPlayer.pause();
            }
        }
    });
    mMediaPlayer.setOnErrorListener(new OnErrorListener() {

        @Override
        public boolean onError(
                MediaPlayer paramMediaPlayer,
                int what, int extra) {
            String message = "Unknown error";
            switch (what) {
            case MediaPlayer.MEDIA_ERROR_UNKNOWN:
                message = "Unable to play media";

                break;
            case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
                message = "Server failed";

                break;
            case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
                message = "Invalid media";

                break;
            }
            Log.e("" + this, message);
            return false;
        }

    });
    mMediaPlayer.prepareAsync();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
我找不到关于那个错误代码的任何信息,但有人告诉我,这可能是因为它用来制作视频的编解码器


提前谢谢。

你解决了这个问题吗?有人解决了吗?你解决了吗?有人解决了吗?