简体   繁体   中英

How to get audio files on my phone using Ionic 2 Cordova plugins?

I have tried the Ionic mediaPlugin

import { MediaPlugin } from 'ionic-native';

var file = new MediaPlugin('path/to/file.mp3');

I'm still confused on how to do that. All I want to do is to create something like a media player, that gets all the audio on a users android phone, and to play and pause it too.

Check this tutorial first it will guide you. However check this too, it will tell you where you have to store your data.

If you do it on android, you should use externalDataDirectory .

  this.filePath = cordova.file.externalDataDirectory;

  this.mediaPlugin = new MediaPlugin(this.filePath + this.directoryName + "/" + this.actualAudioFileName);

After this you can find your data under the following folder on your phone Android/data/yourApplicationId/files/yourDirectoryName

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM