IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Problème d'affichage


Sujet :

Android

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    29
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 29
    Points : 6
    Points
    6
    Par défaut Problème d'affichage
    Bonjour à tous,

    Voila je développe une application composé d'un visuel, des questions sur le visuel, et en cliquant sur les questions on a les réponses dans une vue avec texte, image et vidéo.
    Le texte et l'image s'affiche sans problème, par contre la vidéo ne s'affiche pas.
    Pour cela j'utilise VideoView, je procède de la même manière que pour l'ImageView qui fonctionne, mais ça ne marche pas.
    Et je n'ai pas d'erreurs dans le logcat.
    Voila si quelqu'un peut jeter un oeil et me dire ce qui ne va pas dans mon code.
    Merci d'avance.
    Voila mon code:

    main.xml
    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    	android:id="@+id/RelativeLayout1"
    	android:layout_width="fill_parent"
    	android:layout_height="fill_parent"
    	android:orientation="vertical" >
     
    	<android.opengl.GLSurfaceView
    		android:id="@+id/glSurface"
    		android:layout_width="fill_parent"
    		android:layout_height="fill_parent" />
     
    	<LinearLayout
    		android:id="@+id/LinearLayout1"
    		android:layout_width="wrap_content"
    		android:layout_height="wrap_content"
    		android:layout_alignParentBottom="true"
    		android:layout_alignParentRight="true"
    		android:layout_alignParentTop="true"
    		android:orientation="vertical" >
     
    		<ListView
    			android:id="@+id/listView1"
    			android:layout_width="300dp"
    			android:layout_height="500dp"
    			android:layout_marginBottom="4dp" >
    		</ListView>
     
    		<RelativeLayout
    			android:id="@+id/RelativeLayout2"
    			android:layout_width="match_parent"
    			android:layout_height="200dp"
    			android:layout_marginBottom="2dp"
    			android:layout_marginRight="2dp"
    			android:layout_marginTop="4dp "
    			android:keepScreenOn="true"
    			android:visibility="visible" >
    		</RelativeLayout>
    	</LinearLayout>
     
    	<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    		android:id="@+id/ScrollView1"
        android:layout_width="960dp" 
        android:layout_height="700dp" 
        android:background="#ffffff">
    		<LinearLayout
    		android:id="@+id/LinearLayout2"
    		android:layout_width="950dp"
    		android:layout_height="680dp"
    		android:layout_alignParentLeft="true"
    		android:layout_alignParentTop="true"
    		android:layout_marginLeft="10dp"
    		android:layout_marginTop="10dp"
    		android:background="#ffffff"
    		android:orientation="vertical" android:isScrollContainer="true" android:scrollbarAlwaysDrawVerticalTrack="true" android:scrollbars="vertical">
     
    		<RelativeLayout
    			android:id="@+id/buttonParentLayout"
    			android:layout_width="match_parent"
    			android:layout_height="31dp" >
     
    			<Button
    				android:id="@+id/button1"
    				style="?android:attr/buttonStyleSmall"
    				android:layout_width="wrap_content"
    				android:layout_height="wrap_content"
    				android:layout_alignParentBottom="true"
    				android:text="Fermer"  android:layout_alignParentRight="true"/>
     
    		</RelativeLayout>
     
     
    		<ImageView
    			android:id="@+id/imageviewTest"
    			android:layout_width="wrap_content"
    			android:layout_height="wrap_content"
    			android:src="@drawable/ic_launcher" />
     
    		<VideoView
    			android:id="@+id/videoView1"
    			android:layout_width="match_parent"
    			android:layout_height="wrap_content" />
     
    	</LinearLayout>
    	</ScrollView>
    </RelativeLayout>
    Et voila mon Main.java
    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
     
    public class Main extends Activity{
     
    	GLSurfaceView surfaceView;
    	static Model model = null;
    	InputStream is=null;
    	GestureDetector aGestureDetector;
    	GestureDetector aGestureDetector3D;
    	GestureDetector aNavigatorGestureListener;
    	ImageView imgView=null;
    	ImageView recTransparent=null;
    	MyGLRenderer glRenderer=null;
    	Renderer3D glRenderer3d=null;
    	float xFactor;
    	private ListView lv=null;	
    	View inflatedView;
    	ScaleGestureDetector mScaleDetector=null;
    	Context context = null;
    	WebView webView =null; 
    	NavigatorView aNavigator=null;
    	boolean mExternalStorageAvailable = false;
    	boolean mExternalStorageWriteable = false;
    	ArrayAdapter<Information> lvAdapter;
    	PageWeb pageWeb;
    	String baseUrl;
    	private ArrayList<Information> selectedQuestions;
    	ZoneView zoneView;
    	LinearLayout LinearLayout1;
    	MediaPlayer mediaPlayer;
    	MediasView mediaView;
    	LinearLayout mediasLayout;
    	RelativeLayout buttonParentLayout;
    	Button btnFermer;
    	VideoView myVideoView;
    	SurfaceView surfaceView1;
    	SurfaceHolder surfaceHolder;
     
        @Override
        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.main);
            context = this.getBaseContext();                
     
     
            Log.d("DataDirectory",Environment.getDataDirectory().toString());
        	baseUrl =Environment.getExternalStorageDirectory()+"/Projet";
        	final String rootPath1= Environment.getExternalStorageDirectory()+"/Projet";
     
        	mediasLayout=(LinearLayout) findViewById(R.id.LinearLayout2);
        	mediasLayout.setVisibility(View.GONE);
     
     
        	final ScrollView ScrollView1 = (ScrollView) findViewById(R.id.ScrollView1);
        	ScrollView1.setVisibility(View.GONE);
        	buttonParentLayout = (RelativeLayout) findViewById(R.id.buttonParentLayout);
     
        	btnFermer = (Button) findViewById(R.id.button1);
        	btnFermer.setOnTouchListener(new OnTouchListener() {
    			public boolean onTouch(View arg0, MotionEvent arg1) {
     
    				ScrollView1.setVisibility(View.GONE);
    				return true;
    			}
            });
     
     
            surfaceView = (GLSurfaceView) this.findViewById(R.id.glSurface);
     
            lv = (ListView) this.findViewById(R.id.listView1);
            lvAdapter = new ArrayAdapter<Information>(this,android.R.layout.simple_list_item_1,model.getQuestions());
            lv.setAdapter(lvAdapter);
     
            lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            	public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            	    Object o = lv.getItemAtPosition(position);
            	    Information article =(Information) lv.getItemAtPosition(position);
                	TextView questionView = new TextView(context);
                	questionView.setText(article.toString());
     
                	TextView reponseView = new TextView(context);
                	reponseView.setText(article.getINFORMATION());
     
                	ArrayList<ImageView> imageViews = new ArrayList<ImageView>();
                	ArrayList<VideoView> videoViews = new ArrayList<VideoView>();
     
                	int nbrImg = article.getMEDIAS().size();
                	TextView nbrMedias = new TextView(context);
                	nbrMedias.setText(""+nbrImg);
                	int nbrimg =0;
                	int nbrvideo =0;
     
                	for (int i=0;i<article.getMEDIAS().size();i++){
                		Media media = article.getMEDIAS().get(i);
                		if (media.getMediaType()=="IMAGE") {
                			nbrimg++;
     
                			String imgPath = media.getUri();
            				String strTab[]=imgPath.split("/");
     
            				String newImgPath = rootPath1 + imgPath + "/"+strTab[3];        				
            				FileInputStream in;
            		        BufferedInputStream buf;
                    		Log.d("newImgPath 2  : ",newImgPath);
     
            		        ImageView image = new ImageView(context);
            		        try {
            		       	    in = new FileInputStream(newImgPath);
            		            buf = new BufferedInputStream(in);
            		            Bitmap bMap = BitmapFactory.decodeStream(buf);
            		            image.setImageBitmap(bMap);
     
            		         	imageViews.add(image);
            		            if (in != null) {
            		         	in.close();
            		            }
            		            if (buf != null) {
            		         	buf.close();
            		            }
            		        } catch (Exception e) {
            		            Log.e("Error reading file1", e.toString());
            		        }
     
                		}
     
                		if (media.getMediaType()=="VIDEO") {
                			nbrvideo++;
                			String vidPath = media.getUri();
            				String strTab[]=vidPath.split("/");        				
            				String newVidPath = rootPath1 + vidPath + "/"+strTab[3];        				
                    		Log.d("VideoImgPath   : ",newVidPath);
     
                    		   myVideoView = (VideoView)findViewById(R.id.videoView1);
                    	       myVideoView.setVideoURI(Uri.parse(newVidPath));
     
                    	       myVideoView.setMediaController(new MediaController(context));
                    	       myVideoView.requestFocus();
                    	       videoViews.add(myVideoView);
     
     
     
                		}
     
     
                	}
     
     
                	mediasLayout.removeAllViews();
                	mediasLayout.removeView(questionView);
     
                	mediasLayout.addView(buttonParentLayout);
                	mediasLayout.addView(questionView);
                	mediasLayout.addView(reponseView);
     
                	for(int i=0;i<imageViews.size();i++) {
                		ImageView imgView = imageViews.get(i);
                		mediasLayout.addView(imgView);
                	}
     
     
     
                	for(int i=0;i<videoViews.size();i++) {
                		VideoView videoView=videoViews.get(i);
                		mediasLayout.addView(videoView);
                		//videoView.start();
                		Log.d("VideoViews ","videoViews : "+videoViews.size());
                	}
     
     
     
        	    	mediasLayout.setVisibility(View.VISIBLE);
        	    	ScrollView1.setVisibility(View.VISIBLE);
     
            	  }
            	});
     
     
          glRenderer = new MyGLRenderer(this,model);
          surfaceView.setRenderer(glRenderer); 
          aGestureDetector = new GestureDetector(this, new glSurfaceListener(context,model, lv,lvAdapter,webView,aNavigator));
          mScaleDetector = new ScaleGestureDetector(this, new glSurfaceListener(context,model,lv,lvAdapter,webView,aNavigator));      		
     
     
        }

  2. #2
    Membre régulier
    Homme Profil pro
    Inscrit en
    Février 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Février 2011
    Messages : 59
    Points : 79
    Points
    79
    Par défaut émulateur
    Testes-tu sur l’émulateur ou un phone ? L'emulateur est limité question vidéo.
    Pas de message d'erreur?
    Bonne journée.

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    29
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 29
    Points : 6
    Points
    6
    Par défaut
    Merci deepbreak pour ta réponse,
    je teste sur une tablette samsung galaxy tab, et je n'ai pas d'erreurs dans le logcat.

  4. #4
    Membre régulier
    Homme Profil pro
    Inscrit en
    Février 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Février 2011
    Messages : 59
    Points : 79
    Points
    79
    Par défaut start
    Le MediaController est-il visible dans la vue ? As-tu essayé de rajouter simplement myVideoView.start();
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
                   		   myVideoView = (VideoView)findViewById(R.id.videoView1);
                    	       myVideoView.setVideoURI(Uri.parse(newVidPath));
     
                    	       myVideoView.setMediaController(new MediaController(context));
                    	       myVideoView.requestFocus();
                    	       videoViews.add(myVideoView);
                                   ICI...
    Cordialement.

  5. #5
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    29
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 29
    Points : 6
    Points
    6
    Par défaut
    Non le Mediacontroller n'est pas visible, l’emplacement de la vidéo est vide, j'ai déjà ajouté myVideoView.start(); mais ça n'a rien changé.

  6. #6
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    29
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 29
    Points : 6
    Points
    6
    Par défaut
    Est ce que quelqu'un a une idée pourquoi ma videoView ne fonctionne pas svp?

Discussions similaires

  1. Problème d'affichage
    Par mustang-gx dans le forum Bases de données
    Réponses: 8
    Dernier message: 26/01/2005, 22h54
  2. Problème d'affichage avec trace
    Par WriteLN dans le forum Flash
    Réponses: 10
    Dernier message: 22/10/2003, 16h59
  3. [Kylix] problème d'affichage
    Par scalvi dans le forum EDI
    Réponses: 1
    Dernier message: 18/06/2003, 10h07
  4. Réponses: 1
    Dernier message: 06/03/2003, 11h57
  5. probléme d'affichage d'une fiche
    Par sb dans le forum Composants VCL
    Réponses: 7
    Dernier message: 29/08/2002, 09h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo