How to build app with offline video support features same like youtube in ionic?

I have a requirement where I need to download videos from my app and store them within the app so that the videos are not accessible from the folders, but can be viewed only from the App. the way youtube offline support work same functionality i want it in my app

any one have solution?

Thanks in advance :slight_smile:

4 Likes

hey @amitk04
I want to do the same thing which you’re trying. You achieved it??

Thank in advance :slight_smile:

hey @pallavibiwal
i am trying too much but i am not get any proper solution.

I succeed in doing that by using ionic Filetransfer plugin

import { FileTransfer, FileUploadOptions, FileTransferObject } from ‘@ionic-native/file-transfer’;
constructor(private transfer: FileTransfer,public platform: Platform) {

    this.platform.ready().then(() => {
        // make sure this is on a device, not an emulation (e.g. chrome tools device mode)
        if(!this.platform.is('cordova')) {
          return false;
        }

        if (this.platform.is('ios')) {
          this.storageDirectory = cordova.file.documentsDirectory;
          this.checkFile();
        }
        else if(this.platform.is('android')) {

            file.createDir(file.externalDataDirectory, 'media', true).then((result)=>{

             console.log("Directory created"+result);
            });

            this.storageDirectory = cordova.file.externalDataDirectory+ 'media/';
            console.log(this.storageDirectory);
        }
        else {
          // exit otherwise, but you could add further types here e.g. Windows
          return false;
        }
        
    });

}

download(){
let fileTransfer: FileTransferObject = this.transfer.create();
fileTransfer.download(imageLocation, this.storageDirectory + type+"-"+filename[1]).then((entry) => {
console.log(‘entry:’,entry);
}, (error) => {
console.log(error);
const alertFailure = this.alertCtrl.create({
title: Download Failed!,
//subTitle: was not downloaded. Error code: ${error},
buttons: [‘Ok’]
});

        alertFailure.present(); 
    }); 

}

Hope this help you :slight_smile:

1 Like

okay let me check then i will let you know if i face any issue.

hii, @amitk04
are you get the solution?
If you get the solution then help me.

[pallavibiwal]
can you please explain clearly…

1 Like

great work!!!

but offline video not secure ,
how it is possible? any idea?.. @pallavibiwal

how can offline video will play in ionic 3 app. I am using videogular player for this.