How to implement feature like Youtube offline save video in my ionic app?

How does youtube offline feature works. I want to implement this feature in my app.Is there any solution? Please reply as soon as possible.