2013-06-19 4 views
3

J'essaie de jouer en streaming live avec Vitamio. J'ai corrigé quelques problèmes mais je ne peux pas résoudre ce problème. La vidéo ne joue pas en plein écran. Ce sont mes codes. J'espère que vous pouvez m'aider! Merci et désolé pour mon mauvais anglais.Vitamio plein écran videoview

package com.uusoftware.tvizle; 

import io.vov.vitamio.widget.MediaController; 
import io.vov.vitamio.widget.VideoView; 
import android.app.Activity; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.WindowManager; 

public class Trt extends Activity{ 

    VideoView videoView; 

    private void Trt1(){ 
     String httpLiveUrl = "rtmp://trt-i.mncdn.com/trt1/trt15"; 
     videoView = (VideoView) findViewById(R.id.VideoView); 
     videoView.setVideoURI(Uri.parse(httpLiveUrl)); 
     MediaController mediaController = new MediaController(this); 
     videoView.setMediaController(mediaController); 
     videoView.requestFocus(); 
     videoView.start(); 
    } 


    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.videolayout); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
       WindowManager.LayoutParams.FLAG_FULLSCREEN); 
     Trt1();    
    }  
} 


<?xml version="1.0" encoding="utf-8"?>` 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <io.vov.vitamio.widget.CenterLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <io.vov.vitamio.widget.VideoView 
      android:id="@+id/VideoView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_centerHorizontal="true" 
      android:layout_centerVertical="true" /> 
    </io.vov.vitamio.widget.CenterLayout> 

</LinearLayout> 

Répondre

0

Si vous utilisez le streaming en direct, puis il y a un fichier de mise en page pour le streaming en direct avec le nom de « mediaplayer_2.xml »

changement de la mise en page avec suivante.

<?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:orientation="vertical" > 

<io.vov.vitamio.widget.CenterLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <SurfaceView 
     android:id="@+id/surface" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" > 
    </SurfaceView> 
</io.vov.vitamio.widget.CenterLayout> 

</LinearLayout> 

De cette façon, je résous mon problème.

5

Mettre le VideoView dans un RelativeLayout et le définir comme:

<io.vov.vitamio.widget.VideoView 
     android:id="@+id/vitamioView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentBottom="true" /> 
1

Utilisez cette méthode pour étirer votre VideoView dans la méthode onCreate() de votre activité

mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0); 

Pour gérer onConfigurationChange();

utilisation ci-dessous le code

@Override 
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig); 

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { 

     mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0); 
     Log.e("On Config Change", "LANDSCAPE"); 

    } else { 
     mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0); 
     Log.e("On Config Change", "PORTRAIT"); 
    } 

} 

ajouter également dans votre activité de fichier menifest

android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation" 
0

`package com.uusoftware.tvizle;

import io.vov.vitamio.widget.MediaController; 
import io.vov.vitamio.widget.VideoView; 
import android.app.Activity; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.WindowManager; 

public class Trt extends Activity{ 

private VideoView mVideoView; 

private void Trt1(){ 
    String httpLiveUrl = "rtmp://trt-i.mncdn.com/trt1/trt15"; 
    mVideoView = (VideoView) findViewById(R.id.VideoView); 
    mVideoView.setVideoURI(Uri.parse(httpLiveUrl)); 
    MediaController mediaController = new MediaController(this); 
    mVideoView.setMediaController(mediaController); 
    mVideoView.requestFocus(); 
    mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0); 
    mVideoView.start(); 
} 


public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.videolayout); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    Trt1();    
}  

} `

1
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { 
     mVideoView.setVideoLayout(io.vov.vitamio.widget.VideoView.VIDEO_LAYOUT_STRETCH, 0); 

} else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { 
     mVideoView.setVideoLayout(io.vov.vitamio.widget.VideoView.VIDEO_LAYOUT_ORIGIN, 0); 
} 

merci @Qadir Hussain travail .it pour moi