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

Retrive values from SQLite database
Caused by: java.lang.IllegalArgumentException: provider==null
Android ListView items loose listener if too many items added
How to use Multi-pane layouts with ViewPager
Moving Image from top to bottom in android
how to set H264 profile in android recorder?
how to prevent an async task from cancelling on back button click and at the same time display the previous activity in android
TextView onClick() not working
itemizedoverlay will not show any items on map
What will happen with tables SQLite, If application be re-installed or deleted?
Android TextView in ScrollView not working- Force Close
Titanium doesn't recognize Android SDK on Windows
Mono for Android, How to make an intent that passes data
Socat in Android
Android Listview image size
Getting the ID in a list of fragments in a PagerActivity

Categories

HOME
algorithm
url-redirection
paraview
developer-tools
jmeter
depth
error-handling
access
big-o
python-multithreading
odoo-8
boto3
title
openstreetmap
mxgraph
pybossa
mathprog
git-extensions
soci
simpleitk
symbols
scriptella
dynamically-generated
game-theory
froala
apktool
panoramas
gitlab-api
powershell-ise
hibernate-validator
memory-address
spring-security4
reason
nohup
filesystemwatcher
recurrent-neural-network
apns-php
signals-slots
comparison-operators
tasm
apriori
placeholder
android-checkbox
opencmis
vaadin-elements
pom.xml
dotnet-httpclient
datamaps
tinkerpop
git-flow
avx
boo
check-mk
quicktime
payload
mach-o
rocks
atlas
hadoop-2.7.2
microstation
windows-azure-queues
riot
php-socket
data-protection
cortex-m
halcon
rasterize
forwarding
coda
toolkit
.bash-profile
eoferror
canvg
telepat
git-ftp
jquery-forms-plugin
user-permissions
browserify-shim
administration
entry-point
memset
syndicationfeed
solace-mq
inputmismatchexception
gpars
mysql-error-2013
sqlclr
jquery-blockui
garbage
extconf.rb
isa-swizzling
cgimage
google-maps-mobile
relative
procedures
xcelsius
entitydatasource
tournament
rmdir
inline-formset
silverlight-oob
dsl-tools
commercial-application

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