how to play video from byte array in media player

前端 未结 2 1887
臣服心动
臣服心动 2021-01-06 07:55

i\'m using usb device connected to my android device

this device send me a buffer that contain video frame it dose that continuously .

when i receive the

相关标签:
2条回答
  • 2021-01-06 08:16

    I found jacks205 doesn't mention abstract method close() in Closeable. We also need to write the close(), or the compiling will report the following errors: YourMediaDataSource is not abstract and does not override abstract method close() in Closeable

    0 讨论(0)
  • 2021-01-06 08:26

    I know this is awhile since the question was asked, but I am in the same situation where I have a video transport stream coming through a USB connection.

    It looks like you need to create a data source that extends a MediaDataSource and provides the readAt() and getSize() methods.

    My understanding is Android's MediaPlayer, when you supply a URL/URI as a data source (through setDataSource(), handles all the networking to download the data or retrieve it from storage, and has its own MediaDataSource the player users.

    My plan is to create a service that gets the transport stream from the USB device, and constantly update a custom MediaDataSource that I supply to the MediaPlayer.

    Here is the only thing I could find on the subject, which was a test written for testing using a MediaDataSource with the MediaPlayer. They read a video from a file into a byte array, and then use that array for the readAt() and getSize() methods.

    Only other resources I could find are people supplying strings to the MediaPlayer, but nothing that involves doing their own networking. Also, I'm curious how a constant stream of video is different that just a fixed sized video.

    Edit: I wrote a blog post about MediaDataSource and how to get started with it. Here is the link.

    0 讨论(0)
提交回复
热议问题