MovieView.java revision 666ea1b28a76aeba74744148b15099254d918671
1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.camera; 18 19 20import android.app.Activity; 21import android.content.Intent; 22import android.content.pm.ActivityInfo; 23import android.os.Bundle; 24import android.provider.MediaStore; 25import android.util.Log; 26import android.view.View; 27 28/** 29 * This activity plays a video from a specified URI. 30 */ 31public class MovieView extends Activity { 32 private static final String TAG = "MovieView"; 33 34 private MovieViewControl mControl; 35 private boolean mFinishOnCompletion; 36 37 @Override 38 public void onCreate(Bundle icicle) { 39 super.onCreate(icicle); 40 setContentView(R.layout.movie_view); 41 View rootView = findViewById(R.id.root); 42 Intent intent = getIntent(); 43 mControl = new MovieViewControl(rootView, this, intent.getData()) { 44 @Override 45 public void onCompletion() { 46 if (mFinishOnCompletion) { 47 finish(); 48 } 49 } 50 }; 51 if (intent.hasExtra(MediaStore.EXTRA_SCREEN_ORIENTATION)) { 52 int orientation = intent.getIntExtra( 53 MediaStore.EXTRA_SCREEN_ORIENTATION, 54 ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); 55 if (orientation != getRequestedOrientation()) { 56 setRequestedOrientation(orientation); 57 } 58 } 59 mFinishOnCompletion = intent.getBooleanExtra( 60 MediaStore.EXTRA_FINISH_ON_COMPLETION, true); 61 } 62 63 @Override 64 public void onPause() { 65 mControl.onPause(); 66 super.onPause(); 67 } 68 69 @Override 70 public void onWindowFocusChanged(boolean hasFocus) { 71 if (hasFocus) { 72 Log.v(TAG, "hasFocus"); 73 mControl.onResume(); 74 } 75 } 76} 77