Giter VIP home page Giter VIP logo

Comments (15)

BuddyLReno avatar BuddyLReno commented on August 16, 2024 1

Wish I could help. I've moved on to Xamarin.

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

The -1 problem is solved in this pull request: #197 by @BuddyLReno
Can you maybe try the version from this branch and see if this maybe also fixes the 0 problem you are having?

My guess would be that for some files the duration just can't be detected. Can you share the URL of such a MP3 file?

from cordova-plugin-media.

jb280 avatar jb280 commented on August 16, 2024

This one, does not play and returns 0. But plays fine and give the correct duration if I download it first.

This one plays fine everytime and returns the correct duration. (after a returning couple -1s)

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

Can you help out building a super simple reproduction app with cordova create? Just two play buttons, the functionality to show the duration somehow should be enough. Otherwise anyone looking into this has to do that first.

from cordova-plugin-media.

BuddyLReno avatar BuddyLReno commented on August 16, 2024

@jb280 also try renaming and reuploading the file. Possible something got corrupted when the file was uploaded? Just a guess. Hard to say what the issue is except something with the file itself since they're being served from the same location.

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

I downloaded both files and looked at them (and checked with some "check if mp3 is broken" tools I could quickly google), they look just fine tbh.

from cordova-plugin-media.

jb280 avatar jb280 commented on August 16, 2024

I have a sample using ionic, will that be helpful to you? It seems to be related to either files ize ( perhaps image size embedded in an MP3 tags?) or network latency. The file I'm having trouble with will play more reliably over Wifi, than cellular. Cellular fails 3 times out of 5 times for me, and I get a 0 duration and no audio playing. But other times it does play. The "play working" sample below seems to play 100% of the time.

home.ts

import` { Component } from '@angular/core';

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

@component({
selector: 'page-home',
templateUrl: 'home.html'
})

export class HomePage {

f1 : MediaObject;
f2 : MediaObject;
d1Duration: number = -5;
d2Duration: number = -5;
d1Cnt : number;
d2Cnt: number;
durationCnt1 : number = 0;
durationCnt2 : number = 0;

constructor( private audioFile: Media) {}

PlayNotworking () {
    this.d1Cnt   = 0;
this.f1 = this.audioFile.create("https://s3-us-west-2.amazonaws.com/series-stream/Warring+Spiritually/CD+4+-++Warring+Spiritually.mp3")
this.f1.play();
this.getDuration1();

}

Playworking () {
    this.d2Cnt = 0;
    this.f2 = this.audioFile.create("https://s3-us-west-2.amazonaws.com/series-stream/Fruitful+Repentance/CD+1+-++Fruitful+Repentance.mp3")
    this.f2.play();
    this.getDuration2();

}
StopNotworking () {
    this.f1.stop();
    this.f1.release();
    this.d1Cnt = 0;
    this.d1Duration = -5;
}

Stopworking () {
    this.f2.stop();
    this.f2.release();
    this.d2Cnt = 0;
    this.d2Duration = -5;
}


getDuration1()
{
    setTimeout(() => {
    this.d1Cnt += 1;
        if (    this.d1Cnt > 8 ) {
            return;
        }

        this.d1Duration = this.f1.getDuration();
        console.log("checkDuration  duration = ", this.d1Duration, "d1Cnt = ", this.d1Cnt);
        if (this.d1Duration > 0 )
            return;
        this.getDuration1();

    }, 2000);

}

getDuration2()
{
    setTimeout(() => {
        this.d2Cnt =  this.d2Cnt + 1;
        if ( this.d2Cnt > 8 ) {
            return;
        }
        this.d2Duration = this.f2.getDuration();
        console.log("checkDuration  duration = ", this.d2Duration, "d2Cnt = ", this.d2Cnt);
        if (this.d2Duration > 0 )
            return;
        this.getDuration2();
    }, 2000);

}

}

home.html

Ionic Blank

<button ion-button (click)="Playworking()"> Play Working
<button ion-button (click)="Stopworking()"> Stop/Reset

Duration: {{d2Duration}}    Retry:  {{d2Cnt}}

<button ion-button (click)="PlayNotworking()"> Play Not Working
<button ion-button (click)="StopNotworking()"> Stop/Reset

Duration: {{d1Duration}}    Retry:  {{d1Cnt}}

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

Ionic is fine as well. Please upload the project to Github, so we just have to check it out. Creating a project manually, adding all those files, debugging any build failures etc is a reason not to look into this for any committer.

from cordova-plugin-media.

jb280 avatar jb280 commented on August 16, 2024

https://github.com/jb280/mediaDemo

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

Currently on a Windows machine: Works on Android. Will try iOS later.

from cordova-plugin-media.

jb280 avatar jb280 commented on August 16, 2024

I ran 3 sets of 5 tests on a cellular connection. The most I got was 3 working in one set, the worst was 5 not working. I did get a better result over Wifi. I am still using Ionic 3.18.0 CLI ( because of some things in the larger project), and cordova-plugin-media 5.0.2. Might that be an issue?

My workaround for this project was to download the file with cordova-plugin-file-transfer, and then play it, that works 100% of the time with the same audio files.

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

Ionic CLI has no influence at all at the resulting app. It is just a local tool.
And cordova-plugin-media 5.0.2 is the current version.

But the information that the bug depends on the connection type is interesting. Will take this into account when further testing this.

from cordova-plugin-media.

jb280 avatar jb280 commented on August 16, 2024

Did you have any luck reproducing this on iOS? I still get 2 failures ( getDuration() returns 0) 2 out of 5 time on cellular ( AT&T 3-4bars). The audio never plays. My working of download the whole filed locally first does work, but I don't like the delay of having to download the whole file before starting the audio.

from cordova-plugin-media.

jb280 avatar jb280 commented on August 16, 2024

I now get this in Xcode, when it fails in my real app.
35: CheckRPCError: AudioSessionSetActive_Priv returned server mach error 0x10000003!
Unable to play audio: (null)

getDuration() returns NaN.

It is not on lock-screen, there is no other audio playing. If I turn on WiFi while it is retying the same file it will load and play.
My guess is for that some larger files on a slower link, it might sometimes read zero bytes, and assume it was the EOF, or network error?

from cordova-plugin-media.

ramoniele-batista avatar ramoniele-batista commented on August 16, 2024

Any news on this issue? I download the demo provided by @BuddyLReno on #197, changed the mediaUrl to this and the media duration using the update callback is -1 too.

from cordova-plugin-media.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.