как установить видео в полноэкранном режиме - PullRequest
2 голосов
/ 23 ноября 2010

хай, как установить видео в полноэкранном режиме, теперь я прикрепляю свой скриншот ....

alt text

alt text

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="videothumb.videothumb"
  android:versionCode="1"
  android:versionName="1.0">
 <application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".videothumb" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

   <activity android:name="ViewVideo" android:label="@string/app_name"    
      android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
   <intent-filter><action android:name="android.intent.action.VIEW"></action>
   <category android:name="android.intent.category.DEFAULT"></category>
   </intent-filter>
   </activity>

   </application>
   <uses-sdk android:minSdkVersion="8" />
   <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
   </uses-permission>
   </manifest> 

ViewVideo.java

package videothumb.videothumb;


import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.MediaController;
import android.widget.VideoView;

public class ViewVideo extends Activity {
  private String filename;
  private VideoView Video;
  @Override
  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.main1);
        Video=(VideoView)findViewById(R.id.VideoView01);
        System.gc();
        Intent i = getIntent();
        Bundle extras = i.getExtras();
        filename = extras.getString("videofilename");
        Video.setVideoPath(filename);
        Video.setMediaController(new MediaController(this));
        Video.requestFocus();
        Video.start();
    }

  } `

xml кодирование:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" 
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
<VideoView 
android:id="@+id/VideoView01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent">
</VideoView>
</LinearLayout>

Ответы [ 4 ]

3 голосов
/ 09 февраля 2011

Не требуется код для воспроизведения видео в полноэкранном режиме

Примените следующий формат макета над xml, содержащим видеовид, он наверняка воспроизведет видео в полноэкранном режиме как это работает мой :) Надеюсь, что это помогает

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_alignParentRight="true"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
             android:layout_alignParentBottom="true"
             android:layout_height="fill_parent">
    </VideoView>
 </RelativeLayout>
3 голосов
/ 23 ноября 2010

Вы пробовали это:

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

в вашем классе, который содержит код медиаплеера.

и в вашем xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_alignParentRight="true"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
             android:layout_alignParentBottom="true"
             android:layout_height="fill_parent">
    </VideoView>
 </RelativeLayout>

Надеюсь, это поможет вам.

0 голосов
/ 14 июля 2011

Кстати, в своем манифесте, в этой строке <activity android:name="ViewVideo", вы забыли поставить точку (.) Перед «ViewVideo».Это должно быть ".ViewVideo"

0 голосов
/ 23 ноября 2010

мой файл java:

открытый класс VideoViewDemo расширяет Activity {

VideoView mVideoView;
MediaController mc;
@Override
public void onCreate(Bundle icicle) {
   super.onCreate(icicle);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//if you want.
    File video = new File("your file path");
    mVideoView = (VideoView) findViewById(R.id.surface);
    mc = new MediaController(this);
    mVideoView.setMediaController(mc);
    mc.setAnchorView(mVideoView);
    mVideoView.setMediaController(mc);
    mVideoView.setVideoPath(video.getAbsolutePath());
    mVideoView.requestFocus();
    mVideoView.start();

}                                                                                        

мой макет xml:

и мой файл Menifest:

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...