Tuesday, 15 April 2014

RTSP Android Media player -



RTSP Android Media player -

i trying create rtsp player android, getting error video can't played. don't know whats error making, not working, tried methods, giving code below

import android.media.audiomanager; import android.media.mediaplayer; import android.net.uri; import android.os.bundle; import android.app.activity; import android.app.progressdialog; import android.content.context; import android.content.intent; import android.view.menu; import android.widget.mediacontroller; import android.widget.videoview; public class mainactivity extends activity { videoview myvideoview; progressdialog progdailog; audiomanager audio; mediacontroller mediacontroller; string unstringurl="rtsp://his.dvrdns.org:8554/channel/2"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); myvideoview = (videoview)findviewbyid(r.id.videoplayer); progdailog = progressdialog.show(mainactivity.this, null, "video loading...", true); sound = (audiomanager) getsystemservice(context.audio_service); mediacontroller = new mediacontroller(this); myvideoview.setmediacontroller(mediacontroller); myvideoview.setvideouri(uri.parse(unstringurl)); myvideoview.requestfocus(); myvideoview.setonpreparedlistener(new mediaplayer.onpreparedlistener() { public void onprepared(mediaplayer arg0) { // called rtsp in 4.1 if(progdailog != null) { progdailog.dismiss(); } myvideoview.start(); } }); myvideoview.setoncompletionlistener(new mediaplayer.oncompletionlistener() { public void oncompletion(mediaplayer mp) { /*intent intent = new intent(myvideoview.this, lastactivity); intent.putextra("cletitre", activitytitle); intent.putextra("clesegment", activitycat); startactivity(intent);*/ } }); myvideoview.setonerrorlistener(new mediaplayer.onerrorlistener() { public boolean onerror(mediaplayer mp, int what, int extra) { if(progdailog != null) { progdailog.dismiss(); } homecoming false; } }); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_main, menu); homecoming true; } }

you can seek including net -permisison line in (following line) in app's manifest file.in case worked.

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

hope helps.

android android-layout android-intent android-emulator android-widget

No comments:

Post a Comment