Skip to content Skip to sidebar Skip to footer

Vlc Encountered An Error With This Media Android

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.Buil

Solution 1:

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();

or you can also use VideoView that can play both audio and videos. the implementation will go like this

protectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundleb=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));

    MediaControllermediaController=newMediaController(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" />

Post a Comment for "Vlc Encountered An Error With This Media Android"