I have been trying to play a mp4 video from a remote url/dailymotion .I have played an other video in .3gp format from an other website ,it worked fine ,can not play any video from daily motion in my android app , here is my all code ,can not understand the issue.any help
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/VideoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
`
public class songs extends Activity {
String VideoURL = "http://www.dailymotion.com/video/x2trnoh_indian-girl-mehndi-dance_fun";
VideoView videoview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the layout from video_main.xml
setContentView(R.layout.songs);
// Find your VideoView in your video_main.xml layout
videoview = (VideoView) findViewById(R.id.VideoView);
try {
// Start the MediaController
MediaController mediacontroller = new MediaController(
songs.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
Uri video = Uri.parse(VideoURL);
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(video);
videoview.requestFocus();
videoview.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
videoview.start();
}
});
} catch (Exception e) {
System.out.println("Video Play Error :" + e.getMessage());
}
}}
ASAIK, we can't play the dailymotion video's in normal android video view. So instead of video view Why cant you try thier SDK here and render it in a webview.
Dailymotion provides a WebView based SDK that includes all the tricks required for you to play the video easily :
Github link:: dailymotion-sdk-android/
The README provides an easy example of integration
Hope it helps