Bonjour à tous ,
Je dois faire une application qui lira un flux vidéo avec un lien rtsp .
J'ai beau essayer je n'arrive à rien , peut importe la manière de le faire l'écran reste noir ...
Voici quelques informations sur mon flux video (pris sur VLC où là la lecture fonctionne (sur pc)) :
Codec : H264 - MPEG-4 AVC (part 10) (h264)
Résolution : 800x450
Format décodé: Planar 4:2:0 YUV full scale
Voici les codes que j'ai essayé,aucun d'entre eux n'a fonctionné :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 try{ String uri = "rtsp://user:password@134.246.149.244/axis-media/media.amp?streamprofile=MedonMedium"; VideoView v = (VideoView) findViewById( R.id.videoView ); v.setVideoURI( Uri.parse(uri) ); v.requestFocus(); v.start(); }catch(Exception x) { Log.e("ERROR","" + x); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource("rtsp://user:password@134.246.149.244/axis-media/media.amp?streamprofile=MedonMedium"); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { mp.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } mp.start();
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 public void videoPlayer(String path, boolean autoplay){ try { getWindow().setFormat(PixelFormat.TRANSLUCENT); //the VideoView will hold the video VideoView videoHolder = new VideoView(this); //MediaController is the ui control howering above the video (just like in the default youtube player). videoHolder.setMediaController(new MediaController(this)); //assing a video file to the video holder videoHolder.setVideoURI(Uri.parse(path)); //get focus, before playing the video. videoHolder.requestFocus(); if(autoplay){ videoHolder.start(); } } catch (Exception e) { Log.e("exception",e.toString()); } //get current window information, and set format, set it up differently, if you need some special effects }
Merci d'avance pour toute aide , j'en ai vraiment besoin .
Partager