Cordova插件在手机上获取音频文件

Cordova插件在手机上获取音频文件

本文介绍了如何使用Ionic 2 Cordova插件在手机上获取音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了'离子本机'的Ionic mediaPlugin

I have tried the Ionic mediaPlugin

import { MediaPlugin } from 'ionic-native';

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

我仍然对如何做到这一点感到困惑。我想做的就是创建类似媒体播放器的东西,它可以获取用户Android手机上的所有音频,并播放和暂停它。

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.

如果你在android上做,你应该使用 externalDataDirectory

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);

在此之后,您可以在手机上的以下文件夹下找到您的数据
Android / data / yourApplicationId / files / yourDirectoryName

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

这篇关于如何使用Ionic 2 Cordova插件在手机上获取音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:54