How to play video in VideoView?

videoview not playing video in android
how to play video in android from url
android video view library
custom videoview android example
how to play video from internal storage in android
can't play this video android studio
mediacontroller; videoview android example
how to play video in android from raw folder

I want to play video in VideoView. When I try to do that I got the following error:

Here is my source code:

package com.video.listitem;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.MediaController;
import android.widget.VideoView;

public class PlayVideo extends Activity {

     VideoView mVideoView;
     MediaController mc;
     String videourl;

     @Override
     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.videoplay);

        try {
             mVideoView = (VideoView) findViewById(R.id.videoview);
             String videourl = "rtsp://v7.cache4.c.youtube.com/CiILENy73wIaGQl25yDUbxNXTRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp";
             mc = new MediaController(this);
             mVideoView.setMediaController(mc);
             mVideoView.requestFocus();
             mVideoView.setVideoURI(Uri.parse(videourl));
             mc.show();
             mVideoView.start();
         } catch (Exception e) {
         //TODO: handle exception
         }  
    }
}

Here is my XML File:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="none"
    android:gravity="center">

    <VideoView
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:id="@+id/videoview" />

</LinearLayout>

Try to run app in Device , Video may not run in Emulator...

13.1: Playing video with VideoView · GitBook, The simplest way to play video in your app is to use a VideoView object, which is part of the Android platform. The VideoView class combines a media player (the  In this post we will see how we can play videos in Android using Android VideoView control. The application will play a video from file path (Android’s Internal memory or External memory i.e. SDCard). We will have to manually grant Android permissions to grant access to read phone’s storage. So let’s begin.

see my answere here in the example code provided. If video is not playing try to re-encode it with a program like Handbrake and try again. Info on supported video formats: Android Supported Media Formats

29. HOW TO PLAY VIDEO IN ANDROID STUDIO, How do I fix a video not playing on my Android? In this android programming source code example, we are going to play Youtube video in Android VideoView. You can copy and adopt this source code example to your android project without reinventing the wheel. Below is a step by step source code to play Youtube video in Android VideoView. activity_main.xml.

Try to add permission to connect to internet !

uses-permission android:name="android.permission.INTERNET"

VideoView - Android Studio Tutorial, How do I play videos from internal storage on Android? Adding our video file in the Android App. This is just like how we did in our tutorial for playing an audio file using the MediaPlayer class. Firstly, on the left-hand side of our Android Studio, make sure we are on the PROJECT sidebar and under Android. From here you have to go to app > res > raw.

    public void playVideo() {
            videoView = findViewById(R.id.vid);
 videoView.setVideoPath("rtsp://v7.cache4.c.youtube.com/CiILENy73wIaGQl25yDUbxNXTRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp")
            videoView.start();
        }

Just call this function in your onCreate() method

Play Video In Android Using VideoView, 29. HOW TO PLAY VIDEO IN ANDROID STUDIO | VIDEOVIEW TUTORIAL In this video you Duration: 10:47 Posted: Jul 10, 2016 You can play youtube video in your application.There is no need to add third party library or other API. First of all create one android project named "VideoViewTube".; You need to add VideoView component in your xml file.Open activity_main.xml and add following code:

The answer to this problem may be in this post:

Returning false or not having an OnErrorListener at all will cause the OnCompletionListener to be called.

So return true instead of false from the function and no error will be shown, i.e.

video.setOnErrorListener(new OnErrorListener() {

    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
        Log.d("video", "setOnErrorListener ");
        return true;
    }
});

Advanced Android 13.1: Play video in a VideoView, In this video we will use a VideoView to play a local video file in our app. We will also add a Duration: 4:12 Posted: Nov 20, 2017 Try to play the video (emulator or real device, wherever you're testing) with the regular default media player on Android first. Then you see if you have at least a supported codec. If that's the case, go into your app/VideoView to debug further. This saves some time in case the issue is not with your app but with the video itself.

How to play a Video File in Android Studio using VideoView, Play Video In Android Using VideoView In this video, we will learn how to play a video in Duration: 10:08 Posted: Jul 21, 2017 In this post we shall explore how to play a video using VideoView in Xamarin.Android. You can have a look at the file formats supported by Android VideoView here. First, create a VideoView in your layout file as so :- We can play a video in a VideoView in 3 methods as follows. 1. Playing…

VideoView Tutorial With Example In Android Studio, The simplest possible way to play a video clip in your app, however, is to use the VideoView class to play the video, and the MediaController class as the UI to  We set the VideoUri by specifying the 3gp link of Youtube video for mobile platforms. To add media controls such as Play, Pause, Rewind, Fast Forward and a progress slider ,we add MediaController to the VideoView. uri.parse( 3gp link of the video )you can get this from youtube.

VideoView, Building the Interface of our Video Player Android app. Of all our apps that we have created up until now, you will see that this has the simplest of  The simplest way to play video in your app is to use a VideoView object, which is part of the Android platform. The VideoView class combines a media player (the MediaPlayer class) with a SurfaceView to actually display the video.

Comments
  • can you post your error log..
  • i got like this: 10-10 18:16:14.253: ERROR/PlayerDriver(31): Command PLAYER_PREPARE completed with an error or info PVMFFailure 10-10 18:16:14.253: ERROR/MediaPlayer(5161): error (1, -1) 10-10 18:16:14.263: ERROR/MediaPlayer(5161): Error (1,-1) 10-10 18:16:14.263: DEBUG/VideoView(5161): Error: 1,-1
  • you have include internet permission in your manifest?
  • yes..i done that but still i am facing problem
  • Please post the solution, I am facing the same problem. Thanks
  • yeah i tried it also but facing same problem .. please post the solution :(