![](/img/trans.png)
[英]Play video without interrupting/stopping the background audio in Android
[英]Android, hide video without stopping audio playback
(对不起我的英语不好)
我正在尝试使用TextureView显示视频,但是我需要知道是否有一种隐藏视频而不停止音频播放的方法。
因此,我正在做:
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
mySurface = new Surface(surface);
if(MyService.mMediaPlayer != null) MyService.mMediaPlayer.setSurface(mySurface);
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
if(MyService.mMediaPlayer != null) MyService.mMediaPlayer.setSurface(null);
return false;
}
您可以看到我正在尝试使用setSurface(null),但是尝试此操作时音频不会保留。
编辑:我在主要活动中有一个按钮(“显示视频”); 此按钮将启动第二个活动,在其中放置上面的代码。
我需要在按下“后退”按钮或“主页”按钮时保持音频播放
将您的TextureView
的可见性设置为INVISIBLE
mTextureView.setVisibility(View.INVISIBLE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.