1

I've made application which playing movie in 3gp format. Everything is working great on smartphones. When I installed app on tablet there is strange thing during playing movie. Whole layout is portrait mode but movie is rotated 90 degrees and played landscape (the same size like should be in portrait mode) in this way.

I've set in manifest file android:screenOrientation="portrait" for activity with VideoView. I don't want to display in landscape mode at all.

On smartphones when Autorotation screen is disable - the default orientation is portrait. On tablets default orientation is landscape. Another thing on tablet is when I use Youtube app and choose some movie in portrait mode, there is automatically rotate video, resize and fixed to landscape mode.

I'm not sure it is hardware setting or application what I could change.

Currently on tablets my application is playing movie with rotated view in portrait mode.

EDIT: Manifest file:

   <activity  android:name=".Video" android:screenOrientation="portrait" />

Code:

   ByteArrayInputStream inputStream = new ByteArrayInputStream(cursor.getBlob(2)); //get from database
   stream = inputStream;
   if (stream == null)
      throw new RuntimeException("stream is null");

   try {   
      temp = File.createTempFile("movie", "3gp");
   } catch (IOException e1) {
      e1.printStackTrace();
   }

   temp.deleteOnExit();
   tempPath = temp.getAbsolutePath();

   try {
      out = new FileOutputStream(temp);
   } catch (FileNotFoundException e1) {
      e1.printStackTrace();
   }

   byte buf[] = new byte[128];

   do {
      try {
         numread = stream.read(buf);
      } catch (IOException e) {
         e.printStackTrace();
      }
      if (numread <= 0)
         break;
      try {
         out.write(buf, 0, numread);
      } catch (IOException e) {
         e.printStackTrace();
      }
   } while (true);

   try {
      stream.close();
   } catch (IOException ex) {
      Log.e("ERROR", "error: " + ex.getMessage(), ex);
   }

   final VideoView myVideoView = new VideoView(this);  
   myVideoView.setVideoPath(tempPath);
   myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
      public void onPrepared(MediaPlayer arg0) {
         myVideoView.start();
      }
   });

   myVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
      public void onCompletion(MediaPlayer mp) {
         mp.reset();
         myVideoView.setVideoPath(tempPath);
      }
   }); 
   tl.addView(myVideoView);  //add videoview to table layout

layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="@drawable/tlomain">
    <TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/tlayout"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent">
    </TableLayout>
</RelativeLayout>

All elements on tablet screen are fine according to portrait mode and only video is rotated 90 degrees.

You can see how it looks using Youtube: https://i.stack.imgur.com/qwP5S.jpg

Movie is rotated. On my smartphone the same movie in Youtube app is set normal in horizontal view.

I dont know how to change it in my app. Is it hardware settings? If tablet device want to open 3gp,mp4 format it is rotated 90 degrees to be ready for landscape mode ?

Nate
  • 31,017
  • 13
  • 83
  • 207
Tom B
  • 57
  • 4
  • 9
  • the android:screenOrientation parameter shoul lock the rotation, however if you are somehow overriding this setting in your code, well.. that could be the why, so posting some of your code could help a little. – Raykud Jun 06 '12 at 21:30
  • Thanks for answer. More details added. – Tom B Jun 06 '12 at 21:59

0 Answers0