Ionic 3 and firebase when download an audio it gives an error


Ionic 3 and firebase when download an audio it gives an error



when i try to download an audio from firebase storage it gives me an error .



here is my .ts file


import { FirebaseProvider } from './../../providers/firebase/firebase';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { FirebaseListObservable } from 'angularfire2/database';
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-
native/file-transfer';
import { File } from '@ionic-native/file';
import { NativeAudio } from '@ionic-native/native-audio';

@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {

constructor(private transfer: FileTransfer,private file: File,private
nativeAudio: NativeAudio) {
const fileTransfer: FileTransferObject = this.transfer.create();
this.download();
this.nativeAudio.preloadSimple('uniqueId1', this.file.dataDirectory +
'test.mp3').then((res) => {
console.log('Mp3 ready');
}, (error) => {
console.log("Some error during load the audio "+error);
});

this.nativeAudio.play('uniqueId1').then((onSuccess)=>{
console.log('Mp3 reproduced ok');
}, (onError)=>{
console.log("Some error during reproduce of the audio "+onError);
});

// can optionally pass a callback to be called when the file is done playing
//this.nativeAudio.play('uniqueId1', () => console.log('uniqueId1 is done
playing'));

}


function download() {
const url = 'https://firebasestorage.googleapis.com/v0/b/database-
1b1c9.appspot.com/o/p10_1.mp3?alt=media&token=bb1551d7-7233-4414-ac61-
e6ecd05d1d89';
fileTransfer.download(url, this.file.dataDirectory + 'test.mp3').then((entry)
=> {
console.log('download complete: ' + entry.toURL());
}, (error) => {
console.log('Error during download: '+error);
});
}



and attach pic is an error which im encountering.



enter image description here



kindly help me to remove this error so that i may able to download this audio from storage firebase.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV