android


Phonegap app playing mp3 using Media plugin does not work


I've developed file reader in phonegap with following path:
var defaultPath = 'file:///storage/sdcard0/';
So i'm able to list all file on sdcard and select one folder with audio files to load. So my list of audio files looks like:
i[1] = 'file:///storage/sdcard0/Download/audio/file.mp3';
i[2] = 'file:///storage/sdcard0/Download/audio/file1.mp3';
Then I try to init song using Media plugin ( installed ) with following piece of code:
var media = new Media(i[1]);
media.play();
But audio does not play or do nothing. But when I'm trying to test it using PhoneGap APP all works fine this just isn't work when I make build and try to test app from build.
I found the issue by myself.
Android does not let read files on local storage or on sdcard via path starting from root /storage/sdcard0 /storage/sdcard1. So when we would like to access local storage or sdcard we must access it via file:///mnt/sdcard/ for sdcard and file:///mnt/storage/sdcard1/ for phone storage.
Small example how to read entries from sdcard or phone storage:
var path = 'file:///mnt/storage/sdcard1/';
window.resolveLocalFileSystemURL(path, function(entry){
var reader = entry.createReader();
reader.readEntries(showEntries);
});
function showEntries(entries){
var entries = [];
for(var i =0; i < entries.length; i++){
var entry = entries[i];
var data = {
name: entry.name,
path: entry.fullPath,
};
entries[i] = data;
}
console.log(JSON.stringify(entries));
}
Hope that this will help with same issue as I had because this is not documented in phonegap.

Related Links

Dagger 2 error: “RepositoryImpl cannot be provided without an #Inject constructor or from an #Provides-annotated method”
How to set up event tracking in Intercom through Google Tag Manager
MPAndroidChart Line Chart problems
Stereo recording in android
onClick event doesn't work on nested listview item control in android
How to install the barcode scanning library without a google account?
How to set Android target version in Qt project?
How to open android TeamViewer QuickSupport with Chrome intents (deep link) or any other way from a browser
Unexpected token (position:TEXT) — parsing XML
ListView adapter does not show all requested data
get contact and email id from users phonebook
Android Save the Custom class obj in SQlite DB using SUGAR ORM?
compiling Sony xperia kernel 18.6.A.0.175
How to get the value entered in EditText of android WebView page
android from FragmentPagerAdapter return the current fragment position to calling activity
Intercept button on bluetooth headset

Categories

HOME
string
merge
css3
swt
gradient
sublimetext
nested-if
x264
odoo-8
boto3
performancepoint
github-enterprise
mongodb-csharp
screen-readers
scsi
firefox-addon
red5
jersey-1.0
mapstruct
solrcloud
windows-xp
user-experience
jquery-ias
backpack-for-laravel
pagespeed
parcelable
pchart
object-storage
ckfinder
amazon-quicksight
angular-translate
gnat-gps
magento-1.9.2.4
git-rewrite-history
ideascript
datacachefactory
microsoft-metro
plr
ovf
reportservice2010
geotiff
payara-micro
android-testing
avx
node-request
stax
mta
drawstring
firebase-security
turbo-prolog
contentcontrol
jaunt-api
vigenere
morton-number
fuelcms
extjs-grid
coda
slash
amiga
dnssec
node-serialport
kubuntu
broadband
cross-join
execve
pseudo-class
sql-scripts
machine-instruction
jjaql
ray
mutual-authentication
synapse
multiautocompletetextview
notorm
away3d
isqlquery
cnf
facebook-timeline
argouml
faye
adobe-media-server
thttpd
flex-mobile
matlab-load
mysql-error-1205
lr
http-daemon
nhprof
uideviceorientation
zen
sifr
strtod

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App