1 /*
2  * Copyright (C) 2009 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 
17 package com.example.android.apis.media;
18 
19 import com.example.android.apis.R;
20 import android.app.Activity;
21 import android.content.Intent;
22 import android.os.Bundle;
23 import android.view.View;
24 import android.view.View.OnClickListener;
25 import android.widget.Button;
26 
27 public class MediaPlayerDemo extends Activity {
28     private Button mlocalvideo;
29     private Button mresourcesvideo;
30     private Button mstreamvideo;
31     private Button mlocalaudio;
32     private Button mresourcesaudio;
33     private Button mstreamaudio;
34     private static final String MEDIA = "media";
35     private static final int LOCAL_AUDIO = 1;
36     private static final int STREAM_AUDIO = 2;
37     private static final int RESOURCES_AUDIO = 3;
38     private static final int LOCAL_VIDEO = 4;
39     private static final int STREAM_VIDEO = 5;
40     private static final int RESOURCES_VIDEO = 6;
41 
42     @Override
onCreate(Bundle icicle)43     protected void onCreate(Bundle icicle) {
44         // TODO Auto-generated method stub
45         super.onCreate(icicle);
46         setContentView(R.layout.mediaplayer_1);
47         mlocalaudio = (Button) findViewById(R.id.localaudio);
48         mlocalaudio.setOnClickListener(mLocalAudioListener);
49         mresourcesaudio = (Button) findViewById(R.id.resourcesaudio);
50         mresourcesaudio.setOnClickListener(mResourcesAudioListener);
51 
52         mlocalvideo = (Button) findViewById(R.id.localvideo);
53         mlocalvideo.setOnClickListener(mLocalVideoListener);
54         mstreamvideo = (Button) findViewById(R.id.streamvideo);
55         mstreamvideo.setOnClickListener(mStreamVideoListener);
56     }
57 
58     private OnClickListener mLocalAudioListener = new OnClickListener() {
59         public void onClick(View v) {
60             Intent intent =
61                     new Intent(MediaPlayerDemo.this.getApplication(),
62                             MediaPlayerDemo_Audio.class);
63             intent.putExtra(MEDIA, LOCAL_AUDIO);
64             startActivity(intent);
65 
66         }
67     };
68     private OnClickListener mResourcesAudioListener = new OnClickListener() {
69         public void onClick(View v) {
70             Intent intent =
71                     new Intent(MediaPlayerDemo.this.getApplication(),
72                             MediaPlayerDemo_Audio.class);
73             intent.putExtra(MEDIA, RESOURCES_AUDIO);
74             startActivity(intent);
75 
76         }
77     };
78 
79     private OnClickListener mLocalVideoListener = new OnClickListener() {
80         public void onClick(View v) {
81             Intent intent =
82                     new Intent(MediaPlayerDemo.this,
83                             MediaPlayerDemo_Video.class);
84             intent.putExtra(MEDIA, LOCAL_VIDEO);
85             startActivity(intent);
86 
87         }
88     };
89     private OnClickListener mStreamVideoListener = new OnClickListener() {
90         public void onClick(View v) {
91             Intent intent =
92                     new Intent(MediaPlayerDemo.this,
93                             MediaPlayerDemo_Video.class);
94             intent.putExtra(MEDIA, STREAM_VIDEO);
95             startActivity(intent);
96 
97         }
98     };
99 
100 
101 
102 }
103