Software Archive
Read-only legacy content
17061 Discussions

Audio Player Doesn't Work

Smith__J
Beginner
1,554 Views

I see by searching the forum, that getting audio to play is a very common problem.

I tried the Cordova audio player template but...

1) The downloaded apk would not install, so I couldn't test it. I tried doing Crosswalk, but I am denied permission to extract the zipped folder!

2) It has way too many permissions, that I don't need, and might scare off users.

read phone status and identity
record audio
modify or delete content
full network access
view network connections

Is there ANY simple, straight forward, HTML5 code I could use, not the plugins? Yes, I read the other threads, and it seems nearly impossible. But any help would be appreciate.

BTW, why does it seem simpler to play an MP4 video, than an MP3 audio? That just seems stupid that MP4s are more straightforward to play than MP3s.

 

 

 

0 Kudos
1 Solution
Elroy_A_Intel
Employee
1,554 Views

I recommend using the HTML5 Audio element and JavaScript references. You can find more information at the folowing links:

View solution in original post

0 Kudos
7 Replies
Elroy_A_Intel
Employee
1,555 Views

I recommend using the HTML5 Audio element and JavaScript references. You can find more information at the folowing links:

0 Kudos
Dale_S_Intel
Employee
1,554 Views

>1) The downloaded apk would not install, so I couldn't test it. I tried doing Crosswalk, but I am denied permission to extract the zipped folder!

This is kind of unusual.  Are you able to build and install a simple "blank" app from the Samples?

Dale

 

0 Kudos
Smith__J
Beginner
1,554 Views

Elroy Ashtian Jr (Intel) wrote:

I recommend using the HTML5 Audio element and JavaScript references. You can find more information at the folowing links:

 

Elroy, have you tried this successfully on apps built with XDK?

0 Kudos
Smith__J
Beginner
1,554 Views

Dale, I created a new project, using the html5 video template, no changes, just as is.

I tried putting it on an older smart phone with package installer, and got "there is a problem parsing the package". It installed OK on an Android tablet.

I also downloaded the Crosswalk zipped folder for the new project, still am denied permission to open it.

0 Kudos
Anusha_M_Intel1
Employee
1,554 Views

J.S.

Are you referring to the Audio Player app under HTML5+Cordova samples? https://github.com/gomobile/sample-audio-player/blob/master/docs/README.md

This sample has very simple code for playing audio using HTML5 audio element, Cordova media API and using a low latency plugin for concurrency. 

This is all the code you need to play an audio file using the html5 audio tag:

    <h2>Local audio using HTML5 Audio</h2>
<!--    <p>Musical Compilation</p>-->
    <!--    The HTML5 <audio> tag does not work well in the webviews on many devices. -->
    <div>
    <audio controls>
        <source src="sounds/xylophones-bass-drums-and-snare-drums-ambience.wav" type="audio/wav">
    </audio>
</div>

This will work equally well on mp3 files.We use .wav is because the emulator only supports .ogg and .wav files. Like the comment says we do not always encourage using the html5 audio tag because it doesn't work well on  the webviews of many devices. You can look at the same sample for code that uses the Cordova Media API. 

0 Kudos
Smith__J
Beginner
1,554 Views

Thank you Anusha, yes that is the template I am using. I have not yet gotten it to play, I've tried ogg, wav and mp3, in each of the players. I am now trying my file in the low latency player, I hope that works. One question, can I substitute an MP3 for the wav (boot-sound) that is there for the low latency? I want to have long MP3s, and the wav files are huge. The low latency code does not have extensions on the files.

0 Kudos
Smith__J
Beginner
1,554 Views

Is this player meant only for short audios? I need to use 1 hour long mp3s, and they are not playing on any of the players. The "sound-bowl" on the low latency player works, so it is not that my tablet won't play anything.

0 Kudos
Reply