Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2011 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 package android.media.cts;
     17 
     18 import com.android.cts.stub.R;
     19 
     20 import android.app.Activity;
     21 import android.content.res.AssetFileDescriptor;
     22 import android.content.res.Resources;
     23 import android.media.MediaPlayer;
     24 import android.os.Bundle;
     25 import android.util.Log;
     26 
     27 public class MediaPlayerSurfaceStubActivity extends Activity {
     28 
     29     private static final String TAG = "MediaPlayerSurfaceStubActivity";
     30 
     31     protected Resources mResources;
     32 
     33     private VideoSurfaceView mVideoView = null;
     34     private MediaPlayer mMediaPlayer = null;
     35 
     36     @Override
     37     protected void onCreate(Bundle savedInstanceState) {
     38         super.onCreate(savedInstanceState);
     39 
     40         mResources = getResources();
     41         mMediaPlayer = new MediaPlayer();
     42 
     43         try {
     44             AssetFileDescriptor afd = mResources.openRawResourceFd(R.raw.testvideo);
     45             mMediaPlayer.setDataSource(
     46                     afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
     47             afd.close();
     48         } catch (Exception e) {
     49             Log.e(TAG, e.getMessage(), e);
     50         }
     51 
     52         mVideoView = new VideoSurfaceView(this, mMediaPlayer);
     53         setContentView(mVideoView);
     54     }
     55 
     56     @Override
     57     protected void onResume() {
     58         super.onResume();
     59         mVideoView.onResume();
     60     }
     61 
     62     public void playVideo() throws Exception {
     63         mVideoView.startTest();
     64     }
     65 
     66 }
     67