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 java.util.Map; 21 22 import android.content.Context; 23 import android.graphics.Bitmap; 24 import android.graphics.BitmapFactory; 25 import android.media.MediaMetadataRetriever; 26 import android.net.Uri; 27 import android.util.AttributeSet; 28 import android.util.Log; 29 import android.widget.ImageView; 30 import android.widget.LinearLayout; 31 32 import com.android.mms.R; 33 // TODO: remove dependency for SDK build 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 VideoAttachmentView(Context context)44 public VideoAttachmentView(Context context) { 45 super(context); 46 } 47 VideoAttachmentView(Context context, AttributeSet attrs)48 public VideoAttachmentView(Context context, AttributeSet attrs) { 49 super(context, attrs); 50 } 51 52 @Override onFinishInflate()53 protected void onFinishInflate() { 54 mThumbnailView = (ImageView) findViewById(R.id.video_thumbnail); 55 } 56 startAudio()57 public void startAudio() { 58 // TODO Auto-generated method stub 59 } 60 startVideo()61 public void startVideo() { 62 // TODO Auto-generated method stub 63 } 64 setAudio(Uri audio, String name, Map<String, ?> extras)65 public void setAudio(Uri audio, String name, Map<String, ?> extras) { 66 // TODO Auto-generated method stub 67 } 68 setImage(String name, Bitmap bitmap)69 public void setImage(String name, Bitmap bitmap) { 70 // TODO Auto-generated method stub 71 } 72 setImageRegionFit(String fit)73 public void setImageRegionFit(String fit) { 74 // TODO Auto-generated method stub 75 } 76 setImageVisibility(boolean visible)77 public void setImageVisibility(boolean visible) { 78 // TODO Auto-generated method stub 79 } 80 setText(String name, String text)81 public void setText(String name, String text) { 82 // TODO Auto-generated method stub 83 } 84 setTextVisibility(boolean visible)85 public void setTextVisibility(boolean visible) { 86 // TODO Auto-generated method stub 87 } 88 setVideo(String name, Uri video)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 setVideoThumbnail(String name, Bitmap thumbnail)102 public void setVideoThumbnail(String name, Bitmap thumbnail) { 103 mThumbnailView.setImageBitmap(thumbnail); 104 } 105 createVideoThumbnail(Context context, Uri uri)106 public static Bitmap createVideoThumbnail(Context context, Uri uri) { 107 Bitmap bitmap = null; 108 MediaMetadataRetriever retriever = new MediaMetadataRetriever(); 109 try { 110 retriever.setDataSource(context, uri); 111 bitmap = retriever.getFrameAtTime(-1); 112 } catch (RuntimeException ex) { 113 // Assume this is a corrupt video file. 114 } finally { 115 try { 116 retriever.release(); 117 } catch (RuntimeException ex) { 118 // Ignore failures while cleaning up. 119 } 120 } 121 return bitmap; 122 } 123 setVideoVisibility(boolean visible)124 public void setVideoVisibility(boolean visible) { 125 // TODO Auto-generated method stub 126 } 127 stopAudio()128 public void stopAudio() { 129 // TODO Auto-generated method stub 130 } 131 stopVideo()132 public void stopVideo() { 133 // TODO Auto-generated method stub 134 } 135 reset()136 public void reset() { 137 // TODO Auto-generated method stub 138 } 139 setVisibility(boolean visible)140 public void setVisibility(boolean visible) { 141 // TODO Auto-generated method stub 142 } 143 pauseAudio()144 public void pauseAudio() { 145 // TODO Auto-generated method stub 146 147 } 148 pauseVideo()149 public void pauseVideo() { 150 // TODO Auto-generated method stub 151 152 } 153 seekAudio(int seekTo)154 public void seekAudio(int seekTo) { 155 // TODO Auto-generated method stub 156 157 } 158 seekVideo(int seekTo)159 public void seekVideo(int seekTo) { 160 // TODO Auto-generated method stub 161 162 } 163 } 164