Reputation: 16363
In my app videos are stored as series of encrypted SQLite BLOBs.
In order to play video directly from those SQLite I need to write my own custom ContentProvider
. I know how to implement basic ContentProvider
over SQL queries, but in this case I have no idea how to do this.
How VideoView.setVideoURI()
utilize supplied URI? Either it read is as Cursor
or ParcelFileDescriptor
or somehow as kind of stream?
Any ideas, clues, hints?
Update
Basically question is not only about ContentProvider
, but about streaming/playing video directly from SQLite blobs. It doesn't really matter how to play this video - only precondition: creating of intermediate/temporary video file is prohibited (due to security concerns).
Upvotes: 3
Views: 1993
Reputation: 848
You can use ServerSocket.
As VideoView uri you can set localhost url of the server socket (127.0.0.1:PORT).
After you read blob from SQL and decrypt it, write it to the Socket and VideoView will read and play it.
It won't be stored anywhere (just in memory).
You will need to take care of buffering and synchronization of threads.
I recommend to use 2 threads for ServerSocket (one for accepting connection, second for communication with client).
I have experienced that some specific devices tries to open stream twice. If your thread will be blocked by communication with client and won't accept another connection, it could fail with broken pipe.
Upvotes: 2