1 /* 2 * Copyright (C) 2008 Esmertec AG. 3 * Copyright (C) 2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mms.ui; 19 20 import com.android.mms.R; 21 import android.media.MediaMetadataRetriever; // TODO: remove dependency for SDK build 22 23 import android.content.Context; 24 import android.graphics.Bitmap; 25 import android.graphics.BitmapFactory; 26 import android.net.Uri; 27 import android.util.AttributeSet; 28 import android.util.Log; 29 import android.view.View; 30 import android.widget.ImageView; 31 import android.widget.LinearLayout; 32 33 import java.util.Map; 34 35 /** 36 * This class provides an embedded editor/viewer of video attachment. 37 */ 38 public class VideoAttachmentView extends LinearLayout implements 39 SlideViewInterface { 40 private static final String TAG = "VideoAttachmentView"; 41 42 private ImageView mThumbnailView; 43 44 public VideoAttachmentView(Context context) { 45 super(context); 46 } 47 48 public VideoAttachmentView(Context context, AttributeSet attrs) { 49 super(context, attrs); 50 } 51 52 @Override 53 protected void onFinishInflate() { 54 mThumbnailView = (ImageView) findViewById(R.id.video_thumbnail); 55 } 56 57 public void startAudio() { 58 // TODO Auto-generated method stub 59 } 60 61 public void startVideo() { 62 // TODO Auto-generated method stub 63 } 64 65 public void setAudio(Uri audio, String name, Map<String, ?> extras) { 66 // TODO Auto-generated method stub 67 } 68 69 public void setImage(String name, Bitmap bitmap) { 70 // TODO Auto-generated method stub 71 } 72 73 public void setImageRegionFit(String fit) { 74 // TODO Auto-generated method stub 75 } 76 77 public void setImageVisibility(boolean visible) { 78 // TODO Auto-generated method stub 79 } 80 81 public void setText(String name, String text) { 82 // TODO Auto-generated method stub 83 } 84 85 public void setTextVisibility(boolean visible) { 86 // TODO Auto-generated method stub 87 } 88 89 public void setVideo(String name, Uri video) { 90 try { 91 Bitmap bitmap = createVideoThumbnail(mContext, video); 92 if (null == bitmap) { 93 bitmap = BitmapFactory.decodeResource(getResources(), 94 R.drawable.ic_missing_thumbnail_video); 95 } 96 mThumbnailView.setImageBitmap(bitmap); 97 } catch (java.lang.OutOfMemoryError e) { 98 Log.e(TAG, "setVideo: out of memory: ", e); 99 } 100 } 101 102 public static Bitmap createVideoThumbnail(Context context, Uri uri) { 103 Bitmap bitmap = null; 104 MediaMetadataRetriever retriever = new MediaMetadataRetriever(); 105 try { 106 retriever.setMode(MediaMetadataRetriever.MODE_CAPTURE_FRAME_ONLY); 107 retriever.setDataSource(context, uri); 108 bitmap = retriever.captureFrame(); 109 } catch (RuntimeException ex) { 110 // Assume this is a corrupt video file. 111 } finally { 112 try { 113 retriever.release(); 114 } catch (RuntimeException ex) { 115 // Ignore failures while cleaning up. 116 } 117 } 118 return bitmap; 119 } 120 121 public void setVideoVisibility(boolean visible) { 122 // TODO Auto-generated method stub 123 } 124 125 public void stopAudio() { 126 // TODO Auto-generated method stub 127 } 128 129 public void stopVideo() { 130 // TODO Auto-generated method stub 131 } 132 133 public void reset() { 134 // TODO Auto-generated method stub 135 } 136 137 public void setVisibility(boolean visible) { 138 // TODO Auto-generated method stub 139 } 140 141 public void pauseAudio() { 142 // TODO Auto-generated method stub 143 144 } 145 146 public void pauseVideo() { 147 // TODO Auto-generated method stub 148 149 } 150 151 public void seekAudio(int seekTo) { 152 // TODO Auto-generated method stub 153 154 } 155 156 public void seekVideo(int seekTo) { 157 // TODO Auto-generated method stub 158 159 } 160 } 161