【发布时间】:2016-06-13 10:30:30
【问题描述】:
我用过 https://github.com/krazykira/VidEffects
在播放视频时应用过滤器。 但我想在运行时单击按钮更改过滤器,而不会在播放视频时出现任何故障。
根据 Applying Effects on Video being Played
我应该使用
mVideoView.init(mMediaPlayer,new filter)
每当我想改变过滤器。但播放视频没有效果
谁能帮帮我...我没有使用 GLSurfaceView 的经验。
这是我的java类
public class MainActivity extends Activity {
private static final String TAG = "MediaPlayerSurfaceStubActivity";
protected Resources mResources;
ShaderInterface d = null;
private VideoSurfaceView mVideoView = null;
private MediaPlayer mMediaPlayer = null;
private Button button;
LinearLayout linear;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mVideoView = (VideoSurfaceView) findViewById(R.id.mVideoSurfaceView);
linear = (LinearLayout) findViewById(R.id.linear);
button = (Button) findViewById(R.id.effects);
//HERE , on click of following button I want the effect to be applied at runtime.
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.gc();
mVideoView.init(mMediaPlayer, new VignetteEffect(2));
}
});
mResources = getResources();
mMediaPlayer = new MediaPlayer();
try {
AssetFileDescriptor afd = getAssets().openFd("sample.mp4");
mMediaPlayer.setDataSource(afd.getFileDescriptor(),
afd.getStartOffset(), afd.getLength());
} catch (Exception e) {
e.printStackTrace();
}
mVideoView.init(mMediaPlayer,
new SepiaEffect());
}
@Override
protected void onResume() {
super.onResume();
mVideoView.onResume();
}
}
我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/linear"
tools:context="videoeditor.xcs.com.videoeffect.MainActivity">
<com.sherazkhilji.videffect.view.VideoSurfaceView
android:id="@+id/mVideoSurfaceView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="effects"
android:id="@+id/effects"/>
</LinearLayout>
在这个棕褐色效果已经设置,但我想将其更改为按钮单击时的晕影
【问题讨论】:
标签: android video video-processing glsurfaceview