Note that there are some explanatory texts on larger screens.

plurals
  1. POKindle Fire HD: movies are brighter than jpgs
    text
    copied!<p>I've been working on an app where the user touches the screen to start a movie. The screen image is the first frame of the movie. Once the touch happens, the movie plays. I do this by putting a jpg of the first frame in front of the movie, and then removing the jpg once I think the movie is playing. (Figuring out when that happens is impossible, but that's another issue. And on older devices if you remove the image too soon, you get black.)</p> <p>Tested this on probably six different devices. Today the seventh: Kindle Fire HD. On this device, the movies are all brighter than the corresponding jpgs. On all other devices, they match perfectly. Any ideas what could cause this or how to fix?</p> <p>(Another issue with the HD is that movies take a REALLY long time to start playing. But that's another issue.)</p> <p>EDIT: here is my main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/iv" android:layout_width="fill_parent" android:layout_height="fill_parent"/&gt; &lt;VideoView android:id="@+id/vv" android:layout_width="fill_parent" android:layout_height="fill_parent"/&gt; &lt;/FrameLayout&gt; </code></pre> <p>and here is code:</p> <pre><code>public class VideoTestActivity extends Activity implements SurfaceHolder.Callback, OnPreparedListener, OnCompletionListener { private VideoView vv; private ImageView iv; private Bitmap b; private MediaPlayer mp = new MediaPlayer(); private static final String TAG = VideoTestActivity.class.getSimpleName(); private volatile boolean prepared = false; private volatile boolean readytoplay = false; private volatile boolean playing = false; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); iv = (ImageView)findViewById(R.id.iv); iv.bringToFront(); vv = (VideoView)findViewById(R.id.vv); b = BitmapFactory.decodeResource(getResources(), R.drawable.babyblack); iv.setBackgroundColor( 0xFFDFA679 ); vv.getHolder().addCallback(this); mp.setOnPreparedListener( this ); mp.setOnCompletionListener( this ); try { mp.setDataSource( this, Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.ape) ); } catch (IllegalArgumentException e) { Log.d(TAG,"illegal argument exception on set data source"); e.printStackTrace(); } catch (SecurityException e) { Log.d(TAG,"security exception on set data source"); e.printStackTrace(); } catch (IllegalStateException e) { Log.d(TAG,"illegal state exception on set data source"); e.printStackTrace(); } catch (IOException e) { Log.d(TAG,"IO exception on set data source"); e.printStackTrace(); } } @Override public boolean onTouchEvent(MotionEvent event) { float dx, dy; Log.d(TAG,"touch event"); if ( !playing &amp;&amp; event.getAction() == MotionEvent.ACTION_UP ) { Log.d(TAG,"action up"); if ( prepared ) { playing = true; Log.d(TAG,"hardware accelerated: iv="+iv.isHardwareAccelerated()+", vv="+vv.isHardwareAccelerated()); mp.start(); Log.d(TAG, "playing video in onTouch callback"); Log.d(TAG,"hardware accelerated: iv="+iv.isHardwareAccelerated()+", vv="+vv.isHardwareAccelerated()); } else readytoplay = true; } return true; } @Override public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void surfaceCreated(SurfaceHolder holder) { // TODO Auto-generated method stub Log.d(TAG,"surface is created"); mp.setDisplay( vv.getHolder() ); try { mp.prepareAsync(); } catch (IllegalArgumentException e) { Log.d(TAG,"illegal argument exception on prepare"); e.printStackTrace(); } catch (SecurityException e) { Log.d(TAG,"security exception on prepare"); e.printStackTrace(); } catch (IllegalStateException e) { Log.d(TAG,"illegal state exception on prepare"); e.printStackTrace(); } } @Override public void surfaceDestroyed(SurfaceHolder holder) { // TODO Auto-generated method stub } @Override public void onPrepared(MediaPlayer mp) { Log.d(TAG,"video is prepared"); prepared = true; if ( readytoplay ) { playing = true; mp.start(); iv.setVisibility( View.GONE ); Log.d(TAG,"playing video from prepared callback"); } } @Override public void onCompletion(MediaPlayer arg0) { Log.d(TAG,"video is done"); playing = false; iv.setVisibility( View.VISIBLE ); }} </code></pre> <p>I changed the ImageView to have no image, but just a solid-colored background. The only data file you need is an mp4 movie. When you touch the screen, the movie plays, hidden behind the ImageView. The screen immediately brightens when I touch it (mp.start() happens), then the movie starts playing, and it gradually dims a bit, then brightens again, and finally stabilizes when the movie is done.</p> <p>I tried hardware acceleration, and no hardware acceleration; no difference. I tried plugging the Kindle Fire HD in, and not plugging it in; no difference.</p> <p>I would post the 2-second mp4 file that I am using but don't know how.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload