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 22 import android.content.Context; 23 import android.graphics.Bitmap; 24 import android.graphics.BitmapFactory; 25 import android.media.MediaMetadataRetriever; 26 import android.media.MediaPlayer; 27 import android.net.Uri; 28 import android.util.AttributeSet; 29 import android.util.Log; 30 import android.widget.ImageView; 31 import android.widget.LinearLayout; 32 33 import java.io.IOException; 34 import java.util.Map; 35 36 /** 37 * This class provides an embedded editor/viewer of video attachment. 38 */ 39 public class VideoAttachmentView extends LinearLayout implements 40 SlideViewInterface { 41 private static final String TAG = "VideoAttachmentView"; 42 43 private ImageView mThumbnailView; 44 VideoAttachmentView(Context context)45 public VideoAttachmentView(Context context) { 46 super(context); 47 } 48 VideoAttachmentView(Context context, AttributeSet attrs)49 public VideoAttachmentView(Context context, AttributeSet attrs) { 50 super(context, attrs); 51 } 52 53 @Override onFinishInflate()54 protected void onFinishInflate() { 55 mThumbnailView = (ImageView) findViewById(R.id.video_thumbnail); 56 } 57 startAudio()58 public void startAudio() { 59 // TODO Auto-generated method stub 60 } 61 startVideo()62 public void startVideo() { 63 // TODO Auto-generated method stub 64 } 65 setAudio(Uri audio, String name, Map<String, ?> extras)66 public void setAudio(Uri audio, String name, Map<String, ?> extras) { 67 // TODO Auto-generated method stub 68 } 69 setImage(String name, Bitmap bitmap)70 public void setImage(String name, Bitmap bitmap) { 71 // TODO Auto-generated method stub 72 } 73 setImageRegionFit(String fit)74 public void setImageRegionFit(String fit) { 75 // TODO Auto-generated method stub 76 } 77 setImageVisibility(boolean visible)78 public void setImageVisibility(boolean visible) { 79 // TODO Auto-generated method stub 80 } 81 setText(String name, String text)82 public void setText(String name, String text) { 83 // TODO Auto-generated method stub 84 } 85 setTextVisibility(boolean visible)86 public void setTextVisibility(boolean visible) { 87 // TODO Auto-generated method stub 88 } 89 setVideo(String name, Uri video)90 public void setVideo(String name, Uri video) { 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 } 98 createVideoThumbnail(Context context, Uri uri)99 public static Bitmap createVideoThumbnail(Context context, Uri uri) { 100 Bitmap bitmap = null; 101 MediaMetadataRetriever retriever = new MediaMetadataRetriever(); 102 try { 103 retriever.setMode(MediaMetadataRetriever.MODE_CAPTURE_FRAME_ONLY); 104 retriever.setDataSource(context, uri); 105 bitmap = retriever.captureFrame(); 106 } catch (RuntimeException ex) { 107 // Assume this is a corrupt video file. 108 } finally { 109 try { 110 retriever.release(); 111 } catch (RuntimeException ex) { 112 // Ignore failures while cleaning up. 113 } 114 } 115 return bitmap; 116 } 117 setVideoVisibility(boolean visible)118 public void setVideoVisibility(boolean visible) { 119 // TODO Auto-generated method stub 120 } 121 stopAudio()122 public void stopAudio() { 123 // TODO Auto-generated method stub 124 } 125 stopVideo()126 public void stopVideo() { 127 // TODO Auto-generated method stub 128 } 129 reset()130 public void reset() { 131 // TODO Auto-generated method stub 132 } 133 setVisibility(boolean visible)134 public void setVisibility(boolean visible) { 135 // TODO Auto-generated method stub 136 } 137 pauseAudio()138 public void pauseAudio() { 139 // TODO Auto-generated method stub 140 141 } 142 pauseVideo()143 public void pauseVideo() { 144 // TODO Auto-generated method stub 145 146 } 147 seekAudio(int seekTo)148 public void seekAudio(int seekTo) { 149 // TODO Auto-generated method stub 150 151 } 152 seekVideo(int seekTo)153 public void seekVideo(int seekTo) { 154 // TODO Auto-generated method stub 155 156 } 157 } 158