1017
Views
26
Comments
Solved
play audio in mobile app
Question

I know how play audio files in web apps using HTML5 Goodies, but i don't know how to play audio files in mobile apps.

I have tryed to copy this app over to a mobile app, but failed.

Do someone know have to play audio files in mobile apps?

Plz help

2016-05-04 16-40-03
Carlos Xavier
Staff
Solution

Hi Tobias,

If it is just to play audio, you don't need to use the video widget. Create your own block with the UI you wish and use the Audio JavaScript API to play the file.

UserImage.jpg
MUSGADO

Carlos Xavier wrote:

Hi Tobias,

If it is just to play audio, you don't need to use the video widget. Create your own block with the UI you wish and use the Audio JavaScript API to play the file.


i dont wanna sound dumb or what but can you explain step by step

2019-09-30 07-35-56
Aurelio Junior

Hi,

You can use the "Video" widget to play audio files. Pass it the URL to an audio file, and it will play it.

UserImage.jpg
Tobias Loby

which video widget?

2019-09-30 07-35-56
Aurelio Junior

I assume you're developing a P10 mobile app, right? If so, you have a Video widget available to use in your apps, as shown in the image below:

UserImage.jpg
Tobias Loby

UserImage.jpg
Tobias Loby

UserImage.jpg
Tobias Loby

UserImage.jpg
Tobias Loby

Do i need a "File_ReadBinary" server action to get it to work?

2019-09-30 07-35-56
Aurelio Junior

No, the Video widget only needs the URL of the file to be played. If you're going to play a resource file, you need to set its "Deploy Action" property to "Deploy to Target Directory".

Also, notice that in your resource's properties there's a read-only property called "Runtime Path". This is the path to your resource file. So, the complete URL that you need to pass to the widget would be something like: https://<YourPersonalEnvironment>/<ResourcePath>.

UserImage.jpg
Tobias Loby

UserImage.jpg
Tobias Loby

UserImage.jpg
Tobias Loby

I have no idea :)

2019-09-30 07-35-56
Aurelio Junior

The "SourceFile" property is a Text property, so you need to place the URL between double quotes, like this:

"https://yourpersonalenvironment/yourapp/test/Sound".

What you had in the first image (Resources.sound.URL) should work. Did it not?

UserImage.jpg
Tobias Loby

None off them worked. Can it have something to do with the sound file?

2019-09-30 07-35-56
Aurelio Junior

Maybe. What kind of file is it? Can you share it, so that I can give it a try?

2019-09-30 07-35-56
Aurelio Junior

Ok, here's a simple, working example that plays the file you posted.

AudioTest.oml
UserImage.jpg
Tobias Loby

Thx again for all the help

UserImage.jpg
Tobias Loby

Hi, its me again :)

When you click the video widget you get a video layout with a black background and audio. Is there any way to make a new widget with my own design and make it work?

2016-05-04 16-40-03
Carlos Xavier
Staff

Hi,

Let me just add that Aurelio's solution (using the URL attribute of the resource) also causes the resource to be pre-fetched and available to be played while offline.

2016-05-04 16-40-03
Carlos Xavier
Staff

Hi once again :)

You can play a sound without any interface using the Audio JavaScript API. Take a look at this thread: https://stackoverflow.com/questions/9419263/playing-audio-with-javascript

You may have a JavaScript node with that code inside to play the audio. Pass the resource URL as an input parameter and use it in there.

2019-09-30 07-35-56
Aurelio Junior

Hi Carlos,

Thank you for the info! Let me say that the URL attribute is really useful, and should also be available in web apps.

UserImage.jpg
Tobias Loby

Hi, its me once with my last question

When you click the video widget, you get a full screen video layout with a black background and audio on your phone. Is there any way to make a new widget with my own design and make it still work?

2016-05-04 16-40-03
Carlos Xavier
Staff
Solution

Hi Tobias,

If it is just to play audio, you don't need to use the video widget. Create your own block with the UI you wish and use the Audio JavaScript API to play the file.

UserImage.jpg
MUSGADO

Carlos Xavier wrote:

Hi Tobias,

If it is just to play audio, you don't need to use the video widget. Create your own block with the UI you wish and use the Audio JavaScript API to play the file.


i dont wanna sound dumb or what but can you explain step by step

UserImage.jpg
neoes1um neoesum

Hi,

You can use the "Video" widget to play audio files. Pass it the URL to an audio file, and it will play it.

2019-02-12 09-52-37
Danang Suprayogo




Hy Tobias Loby
I hope this helps

Tobias Loby wrote:


I know how play audio files in web apps using HTML5 Goodies, but i don't know how to play audio files in mobile apps.

I have tryed to copy this app over to a mobile app, but failed.

Do someone know have to play audio files in mobile apps?

Plz help



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.