安卓10自带录屏_谷歌终于在Android 11版里原生支持屏幕录像功能(即录屏)和长截图功能...

在谷歌面向开发者们推出 Android 11 开发者预览版后,关于新版本的越来越多的新增功能正在被逐渐发掘出来。

例如最新被发掘出来的新功能是谷歌终于添加所有用户期待已久的屏幕录像功能,同时还支持进行长截图编辑等。

在谷歌之前其实许多制造商在定制安卓系统时已经增加类似功能,只不过谷歌的动作比较慢没有跟上用户的需求。

诸如屏幕录像和长截图是近年来许多用户都迫切需求的功能,但也直到现在谷歌才决定在安卓里原生支持该功能。

录屏功能方面与其他系统相同:

目前在 Android 11 版里快速操作面板新增录屏功能,当用户点击录屏后系统会弹出提示询问用户是否继续操作。

点击确定后系统开始录制屏幕所有操作生成视频,同时通知栏顶部会显示红色的录屏按钮提醒用户当前正在录屏。

点击通知栏顶部的录屏按钮则可以看到停止、暂停和取消按钮,用户可以在操作时按照自己的需要进行不同操作。

这项功能与目前部分制造商定制安卓系统提供的录屏功能几乎相同,同时也和苹果在 iOS系统里提供的录屏相同。

所以对于用户来说使用应该是没什么问题的,只是还需要等待制造商们适配 Android 11 版后才能使用这项功能。

长截图功能也是用户期待的功能:

长截图功能可以用来截取备忘录或者社交网络上的文章和图片,对于不少用户来说长截图也是非常实用的新功能。

在 Android 11 版里点击截图功能后会在左下角弹出预览图,而长截图功能则是隐藏在预览图右侧的扩展选项里。

不得不说这项功能隐藏的还是挺深的,只有用户先截图才能调用长截图功能然后对屏幕内容再次进行滚动式截图。

在截图完毕后用户可以选择编辑截图或者直接调用系统分享菜单进行分享,至此安卓也终于原生支持长截图功能。 本文来源 XDA,由 山外的鸭子哥 整理编辑,其版权均为 XDA 所有,文章内容系作者个人观点,不代表 蓝点网 对观点赞同或支持。如需转载,请注明文章来源。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 Android MediaCodec 录屏实现的完整代码示例,可以记录屏幕并保存为 MP4 文件。 ``` public class ScreenRecorder { private static final String TAG = "ScreenRecorder"; private static final String MIME_TYPE = "video/avc"; private static final int FRAME_RATE = 30; // 帧率 private static final int I_FRAME_INTERVAL = 1; // I 帧间隔 private static final int BIT_RATE = 6000000; // 比特率 private static final int REQUEST_CODE = 1; private static int width; private static int height; private static int dpi; private MediaProjection mediaProjection; private MediaCodec mediaCodec; private MediaMuxer mediaMuxer; private Surface surface; private VirtualDisplay virtualDisplay; private boolean isRecording; private String outputFilePath; private Context context; public ScreenRecorder(Context context) { this.context = context; } public void startRecording(int resultCode, Intent data) { if (isRecording) { Log.e(TAG, "Already recording"); return; } mediaProjection = createMediaProjection(resultCode, data); if (mediaProjection == null) { Log.e(TAG, "MediaProjection is null"); return; } width = context.getResources().getDisplayMetrics().widthPixels; height = context.getResources().getDisplayMetrics().heightPixels; dpi = context.getResources().getDisplayMetrics().densityDpi; mediaCodec = createMediaCodec(); mediaMuxer = createMediaMuxer(); mediaCodec.start(); virtualDisplay = createVirtualDisplay(); isRecording = true; } public void stopRecording() { if (!isRecording) { Log.e(TAG, "Not recording"); return; } isRecording = false; if (virtualDisplay != null) { virtualDisplay.release(); virtualDisplay = null; } if (mediaCodec != null) { mediaCodec.stop(); mediaCodec.release(); mediaCodec = null; } if (mediaProjection != null) { mediaProjection.stop(); mediaProjection = null; } if (mediaMuxer != null) { mediaMuxer.stop(); mediaMuxer.release(); mediaMuxer = null; } } private MediaProjection createMediaProjection(int resultCode, Intent data) { return ((MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE)) .getMediaProjection(resultCode, data); } private MediaCodec createMediaCodec() { MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, width, height); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); format.setInteger(MediaFormat.KEY_BIT_RATE, BIT_RATE); format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL); MediaCodec codec = null; try { codec = MediaCodec.createEncoderByType(MIME_TYPE); codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); surface = codec.createInputSurface(); } catch (IOException e) { e.printStackTrace(); } return codec; } private MediaMuxer createMediaMuxer() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US); String dateTime = dateFormat.format(new Date()); String fileName = "screen_record_" + dateTime + ".mp4"; outputFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + File.separator + fileName; MediaMuxer muxer = null; try { muxer = new MediaMuxer(outputFilePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4); } catch (IOException e) { e.printStackTrace(); } return muxer; } private VirtualDisplay createVirtualDisplay() { return mediaProjection.createVirtualDisplay(TAG, width, height, dpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC, surface, null, null); } public boolean isRecording() { return isRecording; } public String getOutputFilePath() { return outputFilePath; } } ``` 使用该类,你只需要在你的 Activity 中调用 startRecording() 方法来开始录制,调用 stopRecording() 方法来停止录制。录制完成后,你可以通过调用 getOutputFilePath() 方法来获得输出文件的路径。 以下是一个简单的使用示例: ``` public class MainActivity extends AppCompatActivity { private static final int REQUEST_CODE = 1; private ScreenRecorder screenRecorder; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); screenRecorder = new ScreenRecorder(this); findViewById(R.id.start_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startRecording(); } }); findViewById(R.id.stop_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopRecording(); } }); } private void startRecording() { Intent mediaProjectionIntent = ((MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE)) .createScreenCaptureIntent(); startActivityForResult(mediaProjectionIntent, REQUEST_CODE); } private void stopRecording() { screenRecorder.stopRecording(); } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) { screenRecorder.startRecording(resultCode, data); } } } ``` 补充说明:该代码仅仅是一个简单的示例,可能存在许多潜在问题和优化空间。请在实际使用中自行测试和改进。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值