Can not play a mp4 video in android VIdeoview from a remote url -
i have been trying play mp4 video remote url/dailymotion .i have played other video in .3gp format other website ,it worked fine ,can not play video daily motion in android app , here code ,can not understand 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); // layout video_main.xml setcontentview(r.layout.songs); // find videoview in video_main.xml layout videoview = (videoview) findviewbyid(r.id.videoview); try { // start mediacontroller mediacontroller mediacontroller = new mediacontroller( songs.this); mediacontroller.setanchorview(videoview); // url 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, can't play dailymotion video's in normal android video view. instead of video view why cant try thier sdk here , render in webview.
dailymotion provides webview based sdk includes tricks required play video :
github link:: dailymotion-sdk-android/
the readme provides easy example of integration
hope helps
Comments
Post a Comment