VideoView 无法播放视频文件并显示 mediiaplayer 错误
VideoView cant play the video file and shows mediiaplayer error
我想播放视频,出现无法播放该视频等错误。我正在使用 android 10。
错误 (1-2147483648)
可以是什么?我缺少任何许可或其他内容?
我的代码是:
package com.example.touristguide;
import androidx.appcompat.app.AppCompatActivity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.MediaController;
import android.widget.Spinner;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
Spinner events;
VideoView mumbaiV;
MediaController mediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mumbaiV = findViewById(R.id.videoView);
String event[] = {"Sports", "Events"};
events = findViewById(R.id.static_spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>
(this,R.layout.spinner_text_view,event);
spinnerAdapter.setDropDownViewResource(R.layout.spinner_text_view);
events.setAdapter(spinnerAdapter);
mumbaiV = (VideoView)findViewById(R.id.videoView);
mediaController = new MediaController(MainActivity.this);
Uri uri = Uri.parse("android.resource://com.example.touristguide"+R.raw.mum);
mumbaiV.setMediaController(mediaController);
mediaController.setAnchorView(mumbaiV);
mumbaiV.setVideoURI(uri);
mumbaiV.start();
}
}
Logcat:
2020-09-09 12:39:28.638 16705-16752/com.example.touristguide E/MediaPlayerNative: error (1, -2147483648)
2020-09-09 12:39:28.672 16705-16738/com.example.touristguide W/Gralloc3: mapper 3.x is not supported
2020-09-09 12:39:28.684 16705-16738/com.example.touristguide E/LB: fail to open file: No such file or directory
2020-09-09 12:39:28.687 16705-16705/com.example.touristguide E/MediaPlayer: Error (1,-2147483648)
2020-09-09 12:39:28.688 16705-16705/com.example.touristguide D/VideoView: Error: 1,-2147483648
谢谢。
您提供的路径缺少简单的 /
字符。所以使用这个路径:
Uri uri = Uri.parse("android.resource://com.example.touristguide"+"/"+R.raw.mum);
我想播放视频,出现无法播放该视频等错误。我正在使用 android 10。 错误 (1-2147483648)
可以是什么?我缺少任何许可或其他内容?
我的代码是:
package com.example.touristguide;
import androidx.appcompat.app.AppCompatActivity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.MediaController;
import android.widget.Spinner;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
Spinner events;
VideoView mumbaiV;
MediaController mediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mumbaiV = findViewById(R.id.videoView);
String event[] = {"Sports", "Events"};
events = findViewById(R.id.static_spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>
(this,R.layout.spinner_text_view,event);
spinnerAdapter.setDropDownViewResource(R.layout.spinner_text_view);
events.setAdapter(spinnerAdapter);
mumbaiV = (VideoView)findViewById(R.id.videoView);
mediaController = new MediaController(MainActivity.this);
Uri uri = Uri.parse("android.resource://com.example.touristguide"+R.raw.mum);
mumbaiV.setMediaController(mediaController);
mediaController.setAnchorView(mumbaiV);
mumbaiV.setVideoURI(uri);
mumbaiV.start();
}
}
Logcat:
2020-09-09 12:39:28.638 16705-16752/com.example.touristguide E/MediaPlayerNative: error (1, -2147483648)
2020-09-09 12:39:28.672 16705-16738/com.example.touristguide W/Gralloc3: mapper 3.x is not supported
2020-09-09 12:39:28.684 16705-16738/com.example.touristguide E/LB: fail to open file: No such file or directory
2020-09-09 12:39:28.687 16705-16705/com.example.touristguide E/MediaPlayer: Error (1,-2147483648)
2020-09-09 12:39:28.688 16705-16705/com.example.touristguide D/VideoView: Error: 1,-2147483648
谢谢。
您提供的路径缺少简单的 /
字符。所以使用这个路径:
Uri uri = Uri.parse("android.resource://com.example.touristguide"+"/"+R.raw.mum);