VLC遇到一个错误与该媒体的Android [英] VLC encountered an error with this media Android
问题描述
我一直在努力发挥默认的媒体播放MP3音频文件。从复制的这里我写我的$ C $ ç这样
I have been trying to play an mp3 audio file in the default media player. Copying the code from here I write my code like this
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog
.setCancelable(true)
.setMessage("File Path: " + path + "\n"
+ "Duration: " + duration + "\n"
+ "File Format: " + format + "\n"
+ "File Status: " + status)
.setTitle("File Information")
.setPositiveButton("Play", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Uri uri = null;
uri = Uri.parse(toPlay);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(uri, "audio/mp3");
startActivity(intent);
}
})
.setNegativeButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
其中,路径
和 toPlay
等于的/ mnt / SD卡/音乐/ AEY Nojwan.mp3
。
现在,当我preSS上的对话框中的播放按钮
,VLC播放器打开(不进行选择从已安装的那些球员),并显示具有以下错误对话框:
where path
and toPlay
are equal to /mnt/sdcard/MUSIC/Aey Nojwan.mp3
.
Now when I press the play button on the dialog
, VLC player open (without making a selection of player from the installed ones) and show a dialog with following error:
VLC遇到一个错误与此媒体。请尝试刷新
媒体库
VLC encountered an error with this media. Please try refreshing the media library
我试图卸载VLC,但这样做对我的对话框此播放按钮后
什么都不做。有什么可以是问题。
I tried uninstalling the VLC, but after doing this the play button on my dialog
does nothing. What can be the problem.
推荐答案
我也遇到了这个问题,并用这种方式,也是人们提到使用ACTION_VIEW其他一些方法没有运气,所以我必须处理自己而通过默认的播放器,我认为VLC不能正常接收URI路径。
您可以使用的MediaPlayer类直接播放音频文件,如下图所示。
I also encountered this issue and no luck with using this way and also some other ways that people mentioned to use ACTION_VIEW, so i have to handle myself rather to pass default player, i think VLC is not receiving the Uri path properly. You can use MediaPlayer class to directly play the audio files like below
MediaPlayer mediaPlayer;
mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.m_song);
if(!mediaPlayer.isPlaying())
mediaPlayer.start();
或者你也可以使用VideoView,可以播放音频和视频。实施将是这样的。
or you can also use VideoView that can play both audio and videos. the implementation will go like this
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle b = this.getIntent().getExtras();
String filePath= b.getString("file_path");
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.videoview);
video = (VideoView) findViewById(R.id.surface_view);
video.setVideoURI(Uri.parse(filePath));
MediaController mediaController = new MediaController(this);
video.setMediaController(mediaController);
video.requestFocus();
video.start();
}
<VideoView
android:id="@+id/surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true" />
这篇关于VLC遇到一个错误与该媒体的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!