I want to implement online video playing functionality along with downloading it. I mean same download stream should be used to download and play so that video can be saved
You can create local proxy that will save the stream.
Create two background threads: download thread and streaming thread.
In the streaming thread create ServerSocket and stream data that are just being downloaded.
In the VideoView open the localhost url of your ServerSocket.
You will need to handle buffering, synchronizing threads etc.
With the help of Milos Fec
's answer i solved this issue.
I had to create two thread one for downloading and another for streaming that downloaded content over a socketServer while taking care of synchronisation of data downloaded and data being played.
I have put the whole code as a library on github check here
EDIT: This lib does not work with all the types of videos where video servers imposes restrictions over downloading by breaking video into chunks and so on....
I have tested it with mp4 only. This lib requires a public link.
I worked on this on the early days of my Android development to just learn syncing between local server and remote server. There are a lot of room for improvements in this lib and I am not doing any because there are other options that fulfill the same requirement and I don't get enough time from my other stuff also.