dev_android Posted August 20, 2012 Share Posted August 20, 2012 Bonjour à tous, j'affiche des videos dans un framelayout, mais il y a que la premiere video qui s'affiche, les deux videos se superposent mais je ne sais pas comment resoudre ce probleme, car quand je fais videoview.start() pour les deux videoview le son des deux demarre, mais il y a que la premiére video qui s'affiche, quelqu'un sait comment eviter cette superposition svp?? voila mon code : public class VideoPlayerActivity extends Activity { /** Called when the activity is first created. */ VideoView videoView; VideoView videoView2; public 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.question); String newVidPath= "file:///"+Environment.getExternalStorageDirectory()+"/projet/01.mp4"; LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); FrameLayout videoFrame = (FrameLayout)findViewById(R.id.videoFrameLayout); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(840, 960); layoutParams.gravity = Gravity.CENTER; videoFrame.setLayoutParams(layoutParams); videoView = (VideoView) inflater.inflate(R.layout.video, null); MediaController mediaController = new MediaController(this); mediaController.setAnchorView(videoView); videoView.setMediaController(mediaController); videoView.setVideoURI(Uri.parse(newVidPath)); videoFrame.addView(videoView); String newVidPath2= "file:///"+Environment.getExternalStorageDirectory()+"/projet/02.mp4"; LayoutInflater inflater2 = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); FrameLayout videoFrame2 = (FrameLayout)findViewById(R.id.videoFrameLayout); LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(840, 960); layoutParams2.gravity = Gravity.CENTER; videoFrame2.setLayoutParams(layoutParams2); videoView2 = (VideoView) inflater2.inflate(R.layout.video, null); MediaController mediaController2 = new MediaController(this); mediaController2.setAnchorView(videoView2); videoView2.setMediaController(mediaController2); videoView2.setVideoURI(Uri.parse(newVidPath2)); videoFrame2.addView(videoView2); } } et le XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF" android:orientation="vertical" > <LinearLayout android:id="@+id/LayoutVideos" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FFFFFF" android:orientation="vertical" > <FrameLayout android:id="@+id/videoFrameLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:paddingTop="200dp" > </FrameLayout> </LinearLayout> </LinearLayout> Link to comment Share on other sites More sharing options...
dev_android Posted August 21, 2012 Author Share Posted August 21, 2012 Quelqu'un a une idée svp, je suis vraiment bloqué et je ne sais pas quoi faire? Link to comment Share on other sites More sharing options...
chpil Posted August 21, 2012 Share Posted August 21, 2012 Vu que tu ne définis qu'une seule FrameLayout dans ton XML pour recevoir les vidéos, et que insères ces 2 vidéos au même endroit, c'est normal qu'elles se supperposent. Il te faudrait définir dans ton XML deux zones distinctes, une pour chacune de tes vidéos Link to comment Share on other sites More sharing options...
dev_android Posted August 22, 2012 Author Share Posted August 22, 2012 Merci chpil pour ton aide, j'ai reglé le problème avec un bouton next pour naviguer entre mes videos. ce qui m'envoie vers un autre problème, mon bouton s'affiche partout même si je n'ai pas de video, comment je pourrai faire pour afficher le bouton que s'il y a des videos?? Link to comment Share on other sites More sharing options...
chpil Posted August 22, 2012 Share Posted August 22, 2012 Tu peux jouer programmatiquement avec la visibilité de ton/tes boutons. Tu peux faire quelque chose comme cela buttonNext.setVisibility(View.INVISIBLE); // pour rendre invisible ton bouton, ou View.VISIBLE pour le rendre visible Link to comment Share on other sites More sharing options...
dev_android Posted August 22, 2012 Author Share Posted August 22, 2012 Merci beaucoup ça marche. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.