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

谁说胖子不能爱 提交于 2020-01-22 02:13:43

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/41396525/how-to-get-audio-files-on-my-phone-using-ionic-2-cordova-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!