ionic-audio icon indicating copy to clipboard operation
ionic-audio copied to clipboard

No streaming audio - buffering in iOS

Open pauval08 opened this issue 8 years ago • 27 comments

I don't know if this is a cordova-plugin-media issue, but on iOS the AVPlayer does not play the file right away. It takes about 7-10 seconds to download the entire file then it starts playing. Is it supposed to force the stream in the progressive download from an HTTPS source (amazon s3)?

pauval08 avatar Feb 19 '17 18:02 pauval08

The same happens to me, with my slow Internet takes about 40 seconds to audio starts

CesarOliveira avatar Feb 23 '17 11:02 CesarOliveira

Does progressive download work if you set the plugin to use HTML audio?

arielfaur avatar Feb 23 '17 13:02 arielfaur

How can I do that?

Does progressive download work if you set the plugin to use HTML audio?

CesarOliveira avatar Feb 23 '17 13:02 CesarOliveira

If you run the project with ionic serve it uses HTML audio by default

arielfaur avatar Feb 23 '17 13:02 arielfaur

I see, yes with HTML audio plays right away.

CesarOliveira avatar Feb 23 '17 13:02 CesarOliveira

I guess the issue is then related to the Media plugin

arielfaur avatar Feb 23 '17 13:02 arielfaur

I found this PR https://github.com/apache/cordova-plugin-media/pull/62 from a year ago that solves the streaming in cordova-plugin-media 🤔

CesarOliveira avatar Feb 23 '17 13:02 CesarOliveira

Yeah I have that streaming code in my plugin src, it looks like it was merged over a year ago. It is still not streaming though. I tried dumping the plugins and reinstalling everything but the issue persists.

pauval08 avatar Feb 23 '17 14:02 pauval08

I was able to perform the streaming of mp3 file, the trick is use mu3 file instead your mp3 file.

So I get my mp3 file e create a mu3 file like this:

#EXTM3U
#EXTINF:924, Example artist - Example title
http://s3.amazonaws.com/path/my_audio_file.mp3

The 924 number after #EXTINF: represents the time of the audio (my_audio_file.mp3) in seconds.

More about M3U: Click Here

And save the above file as file.m3u

Then I upload the m3u file and change in the controller to use it, instead of mp3 file. And plays right away.

But the ionic-audio dosen't works 100% with mu3 file, @arielfaur take a look: error

The progress bar works fine, but the size of the time gets broken, I think this is simple to adjust.

Best regards folks

CesarOliveira avatar Feb 24 '17 12:02 CesarOliveira

Thanks Cesar! Life saver info! I was struggling with this for a while and was about to just force html5 audio. :)

pauval08 avatar Feb 24 '17 18:02 pauval08

@pauval08 , how did you this? post your code please

rodolfosaraiva avatar Mar 09 '17 18:03 rodolfosaraiva

Hey I got this working and load times are much better. However, seekTo no longer works! Did you have this issue too? Any solutions?

Many thanks!

ChromaticMind avatar May 21 '17 03:05 ChromaticMind

Hi ceaser. I was build an online radio streaming radio app. I had 10 sec lagging. So i used your method. Created mu3 amd m3u files. Hosted them in server. But i cannot stream them.

jags619 avatar Aug 19 '17 16:08 jags619

@jags619 use m3u files only works with the cordova plugin media: https://github.com/apache/cordova-plugin-media, but I'm still facing some other issues yet such as get the duration of the media, get the current position and others.

CesarOliveira avatar Aug 22 '17 12:08 CesarOliveira

@CeasarOliveira I used cordova plugin media but it is not playing. The m3u file is hosted at http://crawler.quackfoot.com/acorab.m3u. The m3u file is being played at vlc though. It doesnot play in android.

On Tue, Aug 22, 2017 at 5:47 PM, CesarOliveira [email protected] wrote:

@jags619 https://github.com/jags619 use m3u files only works with the cordova plugin media: https://github.com/apache/cordova-plugin-media, but I'm still facing some other issues yet such as get the duration of the media, get the current position and others.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielfaur/ionic-audio/issues/95#issuecomment-324005390, or mute the thread https://github.com/notifications/unsubscribe-auth/AF5iHE-RqqIH7stj7u_7Ap3UKGdLXEwaks5sasNogaJpZM4MFi5j .

jags619 avatar Aug 25 '17 03:08 jags619

@jags619 I test your m3u file in my app on iOS and works fine I don't have an android to test it =(

here is the code:

import { Media, MediaObject } from 'ionic-native/media';

export class TestPage { constructor(private media: Media) { this.media.create("http://crawler.quackfoot.com/acorab.m3u"); this.media.play(); this.media.pause(); } }

and also import Media in app.module.ts

CesarOliveira avatar Aug 25 '17 13:08 CesarOliveira

@CeasarOliviera I am using ionic 1 angular js. and have app.js as main js file. I donot know how to implement this typescript in there. Can you help me

On Fri, Aug 25, 2017 at 6:46 PM, CesarOliveira [email protected] wrote:

@jags619 https://github.com/jags619 I test your m3u file in my app on iOS and works fine I don't have an android to test it =(

here is the code:

import { Media, MediaObject } from '';

export class TestPage { constructor(private media: Media) { this.media.create("http://crawler.quackfoot.com/acorab.m3u"); this.media.play(); this.media.pause(); } }

and also import Media in app.module.ts

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielfaur/ionic-audio/issues/95#issuecomment-324913287, or mute the thread https://github.com/notifications/unsubscribe-auth/AF5iHBiUJqGPqPD1x8vMh_sWSOCFfvwhks5sbsW_gaJpZM4MFi5j .

jags619 avatar Aug 26 '17 06:08 jags619

I am using cordova plugin cordova-plugin-media for ionic 1 version. and code is

var src="http://crawler.quackfoot.com/acorab.m3u"; var my_media = new Media(src, onSuccess, onError);

my_media.play();

I cannot play the sound.

On Sat, Aug 26, 2017 at 11:52 AM, Jags ojha [email protected] wrote:

@CeasarOliviera I am using ionic 1 angular js. and have app.js as main js file. I donot know how to implement this typescript in there. Can you help me

On Fri, Aug 25, 2017 at 6:46 PM, CesarOliveira [email protected] wrote:

@jags619 https://github.com/jags619 I test your m3u file in my app on iOS and works fine I don't have an android to test it =(

here is the code:

import { Media, MediaObject } from '';

export class TestPage { constructor(private media: Media) { this.media.create("http://crawler.quackfoot.com/acorab.m3u"); this.media.play(); this.media.pause(); } }

and also import Media in app.module.ts

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielfaur/ionic-audio/issues/95#issuecomment-324913287, or mute the thread https://github.com/notifications/unsubscribe-auth/AF5iHBiUJqGPqPD1x8vMh_sWSOCFfvwhks5sbsW_gaJpZM4MFi5j .

jags619 avatar Aug 27 '17 03:08 jags619

@jags619 if you change the URL http://crawler.quackfoot.com/acorab.m3u for another URL of a MP3 file, the MP3 plays the sound?

CesarOliveira avatar Aug 28 '17 12:08 CesarOliveira

#cesarOlivieira. Yes it does but its around 10 sec lag.

On Mon, Aug 28, 2017 at 6:38 PM, CesarOliveira [email protected] wrote:

@jags619 https://github.com/jags619 if you change the URL http://crawler.quackfoot.com/acorab.m3u for another URL of a MP3 file, the MP3 plays the sound?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielfaur/ionic-audio/issues/95#issuecomment-325345141, or mute the thread https://github.com/notifications/unsubscribe-auth/AF5iHCEv-BPNNrpgPPu7hQZCZtQzQDbXks5scrhNgaJpZM4MFi5j .

jags619 avatar Aug 28 '17 13:08 jags619

The lag its because it download the file first. It seems your code its ok but I don't know why your m3u file doesn't work, in iOS works fine and I don't have an android to test . Remember that you have to run on the device.

CesarOliveira avatar Aug 28 '17 14:08 CesarOliveira

Yes i am running on real device. Is there other way of directly playing instead of first downloading the file/meta-data

On Mon, Aug 28, 2017 at 8:03 PM, CesarOliveira [email protected] wrote:

The lag its because it download the file first. It seems your code its ok but I don't know why your m3u file doesn't work, in iOS works fine and I don't have an android to test . Remember that you have to run on the device.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielfaur/ionic-audio/issues/95#issuecomment-325366419, or mute the thread https://github.com/notifications/unsubscribe-auth/AF5iHJTO9fJm8YYZQxBi6ouxQSfNa0upks5scsxHgaJpZM4MFi5j .

jags619 avatar Aug 28 '17 15:08 jags619

There is this other plugin: https://ionicframework.com/docs/native/streaming-media/

But I think it doesn't work for Ionic 1

CesarOliveira avatar Aug 29 '17 13:08 CesarOliveira

Tried this also same issue audio lagging

On 29 Aug 2017 19:17, "CesarOliveira" [email protected] wrote:

There is this other plugin: https://ionicframework.com/ docs/native/streaming-media/

But I think it doesn't work for Ionic 1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielfaur/ionic-audio/issues/95#issuecomment-325664813, or mute the thread https://github.com/notifications/unsubscribe-auth/AF5iHIe6rXBKraxNj0Ilbe8YreaXsmmhks5sdBMEgaJpZM4MFi5j .

jags619 avatar Aug 29 '17 13:08 jags619

@CesarOliveira did you solved the problem with seekTo and duration of media using m3u? I'm facing the same problem, I tried a lot of solutions but none of them solved the problem.

dayvsonsales avatar Mar 06 '20 23:03 dayvsonsales

@CesarOliveira did you solved the problem with seekTo and duration of media using m3u? I'm facing the same problem, I tried a lot of solutions but none of them solved the problem.

sadly no, I had to deal with other projects

CesarOliveira avatar Mar 08 '20 13:03 CesarOliveira

@CesarOliveira did you solved the problem with seekTo and duration of media using m3u? I'm facing the same problem, I tried a lot of solutions but none of them solved the problem.

sadly no, I had to deal with other projects

:( Thank you for your answer. I'm considering changing the technology of my app because ionic seems a legacy technology already.

dayvsonsales avatar Mar 08 '20 21:03 dayvsonsales