android exo解码问题,android – 使用ExoPlayer再现加密视频

本文探讨了在Android中使用ExoPlayer播放本地加密视频的问题。通过创建自定义DataSource并覆盖open()、read()和close()方法来实现即时解密,但遇到了‘Top bit not zero’的异常。作者分享了自定义DataSource的代码,并提到加密视频的生成方式,寻求解决方案。
摘要由CSDN通过智能技术生成

我在

Android中使用

ExoPlayer,我正在尝试重现本地存储的加密视频.

ExoPlayer的模块化允许创建可以注入到ExoPlayer中的自定义组件,这种情况似乎如此.事实上,经过一些研究,我意识到,为了完成任务,我可以创建一个自定义的DataSource并覆盖open(),read()和close().

我也发现了this solution,但实际上这里整个文件是一步解密并存储在一个清晰的输入流中.这在很多情况下可以很好.但是如果我需要重现大文件怎么办?

所以问题是:如何在ExoPlayer中复制加密的视频,“即时”解密内容(不解密整个文件)?这可能吗

我尝试创建一个具有open()方法的自定义DataSource:

@Override

public long open(DataSpec dataSpec) throws FileDataSourceException {

try {

File file = new File(dataSpec.uri.getPath());

clearInputStream = new CipherInputStream(new FileInputStream(file), mCipher);

long skipped = clearInputStream.skip(dataSpec.position);

if (skipped < dataSpec.position) {

throw new EOFException();

}

if (dataSpec.length != C.LENGTH_UNBOUNDED) {

bytesRemaining = dataSpec.lengt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要添加自定义可滑动的进度条,你需要在代码中创建自定义的 `SeekBar` 控件,然后将其添加到 `StyledPlayerControlView` 中。 以下是一个简单的示例: 1. 创建自定义的 `SeekBar` 控件 ```java public class CustomSeekBar extends SeekBar { public CustomSeekBar(Context context) { super(context); } public CustomSeekBar(Context context, AttributeSet attrs) { super(context, attrs); } public CustomSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean onTouchEvent(MotionEvent event) { if (!isEnabled()) { return false; } switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_UP: // 在这里处理SeekBar的滑动事件 break; } return true; } } ``` 在 `onTouchEvent` 方法中,你可以处理 `SeekBar` 的滑动事件。 2. 将自定义的 `SeekBar` 添加到 `StyledPlayerControlView` 中 ```java StyledPlayerView playerView = findViewById(R.id.player_view); playerView.setControllerVisibilityListener(new PlayerControlView.VisibilityListener() { @Override public void onVisibilityChange(int visibility) { if (visibility == View.VISIBLE) { // 获取控制器视图 ViewGroup controlView = playerView.findViewById(R.id.exo_controller); // 创建自定义的SeekBar CustomSeekBar customSeekBar = new CustomSeekBar(playerView.getContext()); // 设置SeekBar样式和布局参数 customSeekBar.setProgressDrawable(ContextCompat.getDrawable(playerView.getContext(), R.drawable.seekbar_progress)); customSeekBar.setThumb(ContextCompat.getDrawable(playerView.getContext(), R.drawable.seekbar_thumb)); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.BOTTOM; customSeekBar.setLayoutParams(layoutParams); // 将SeekBar添加到控制器视图中 controlView.addView(customSeekBar); } } }); ``` 在 `onVisibilityChange` 方法中,你可以获取控制器视图,并在其中添加自定义的 `SeekBar`。 这样,你就可以在 `StyledPlayerView` 中添加自定义的可滑动进度条了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值