TextureView
您使用需要 Android API 14 和硬件加速来实现视频裁剪效果。我在这里的文章中描述了它。
您还可以使用我的TextureVideoView
- 基于 android 的自定义视图,TextureView
它使您能够轻松播放和裁剪视频。这非常类似于ImageView#setScaleType
布局
<com.dd.crop.TextureVideoView
android:id="@+id/cropTextureView"
android:layout_width="fill_parent"
android:layout_height="100dp"/>
代码
TextureVideoView cropTextureView = (TextureVideoView) findViewById(R.id.cropTextureView);
// Use `setScaleType` method to crop video
cropTextureView.setScaleType(TextureVideoView.ScaleType.TOP);
// Use `setDataSource` method to set data source, this could be url, assets folder or path
cropTextureView.setDataSource("http://www.w3schools.com/html/mov_bbb.mp4");
cropTextureView.play();
希望这会对某人有所帮助!