question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MediaObject delay when playing short mp3 files

See original GitHub issue

I’m attempting to play a short 3-second audio file on loop. In my real application, this is a silent file. I run important logic every time MediaStatus is called, and this logic is best called frequenty, hence the short length. For testing purposes, it is the jaws hit instead of silence.

My problem is there is a large amount of delay between files where nothing is playing. There is no delay when initially playing the first audio file, but then when looping the file using MediaStatus, there is long silences in between loops (sometimes >30 seconds long). You can see my code here, but main logic is in the MediaStatus handler:

app.intent('MediaStatus', (conv) => {
    console.log('[MediaStatus]');
    const mediaStatus = conv.arguments.get('MEDIA_STATUS');
    if (!mediaStatus || mediaStatus.status !== 'FINISHED') {
        return conv;
    }
    conv.ask(`<speak><audio src="${shortAudio}"><desc>Silent while waiting...</desc></audio></speak>`);
    conv.ask(new MediaObject({
        name: 'short audio loop',
        description: 'testing auto play',
        url: shortAudio,
        icon: new Image({
            url: 'https://s3-us-west-2.amazonaws.com/www.heymuse.com/images/hey-muse-large.png',
            alt: 'Logo',
        })
    }));
    conv.ask(new Suggestions('cancel'));
    return conv;
});

I’ll attach my DialogFlow export MediaTester.zip

Note: this delay is most prominent on google home devices. The delay is not as long in the simulator.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
joecainecommented, Jan 24, 2019

We’ve experienced this too. If you replay a MediaObject that has already been played before during the session, the ‘Google Voice Service’ holds the request for around 30 seconds about 50% of the time, causing a long lag for the user

2reactions
talkingnewscommented, May 19, 2020

I have recently discovered that Media is not supported at all any more by API v2, I see there is an API v3 alpha, but I don’t know how to use it or, nor whether it supports streaming. I’m currently investigating the issue and collating info and will post in a few days (remind me if I forget!)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Re: [PhoneGap] Android slow on starting audio play() using Media ...
In my application I have to play several short mp3 files in a row. But on > android device playing is slow. Actually...
Read more >
android - Why MediaPlayer delayes in playing mp3 audio?
There is an audio latency issue in the Android operating system. There is a few milliseconds delay while audio recording and audio playing....
Read more >
Phonon : Add delay in between queue - Qt Centre Forum
I am using a mediaobject and enqueue to play 5 mp3 files. Is it possible that the first two files are played back...
Read more >
MediaPlayer - Android Developers
MediaPlayer class can be used to control playback of audio/video files and ... Creation of and all access to player instances should be...
Read more >
Slow Windows Media Player startup when playing MP3 files
For some time now I experience the 10 - 25 second delay when playing a MP3 file in WMP. This delay appears to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found