Giter VIP home page Giter VIP logo

Comments (10)

CVeniamin avatar CVeniamin commented on August 16, 2024 1

@janpio, Thank you for such a quick reply!
I looked through the XCode logs and got crashing error "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Seeking is not possible to time {INVALID}'" and a SO comment suggested that Content-Lengthand Content-Range might not be correctly setted thus seekToTime crashes.

I'll open a issue on cordova-plugin-ionic-webview to see what can be changed to properly set the request header for local files and see if that change actually helps.

Thanks again!

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024 1

Maybe you can also confirm the behavior by having a small PHP script return a "media file" without those headers and one with the appropriate headers - then we are sure that is the reason for this problem and can close this here as it is definitely caused by the server.

from cordova-plugin-media.

ghenry22 avatar ghenry22 commented on August 16, 2024 1

If you're using the media plugin to playback your audio you need to give it a native local file path to the local file.

If you're using the html5 audio tag to play then you can use the http:// url that goes through the local webserver.

Note there were some issues with the ionic webview where the local server was not providing range headers which caused seeking in a file to fail.

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

That is very much possible.
Is it possible to debug/understand the requests made from the plugin to the local server?
Did you debug the requests made to a remote URL and compare?

Also, did you open an issue with cordova-plugin-ionic-webview? They probably know better how their webserver works or doesn't work so might be more suited to give you an answer.

from cordova-plugin-media.

CVeniamin avatar CVeniamin commented on August 16, 2024

I have checked the headers that are sent by WebServer and it's correctly setting Content-Length containing size of audio file in bytes however doesn't set Content-Range because file itself is totally server and not streamed in chunks thus previous StackOverflow comment doesn't apply in this case.

Just for further reference in case anyone experiences same issue.
I hard-coded one value timeScale which seems to be 0 or nil to 600 which seems to be working just fine.
It seems that AVPlayer doesn't seem to set currentItem.asset.duration.

That was a dirty fix, however a more elegant solution would be to check if avPlayer.currentItem.asset.duration and avPlayer.currentItem.asset.duration.timescale itself are valid if not then use a hard-coded value.

Thus following lines would change from:

int32_t timeScale = avPlayer.currentItem.asset.duration.timescale;
CMTime timeToSeek = CMTimeMakeWithSeconds(posInSeconds, timeScale);

Then dirty fix applied would look like this:

 int32_t timeScale;
 CMTime duration = avPlayer.currentItem.asset.duration;
 if (CMTIME_IS_INVALID(duration)) {
     timeScale = 600;
 } else {
     timeScale = duration.timescale; 
}

from cordova-plugin-media.

janpio avatar janpio commented on August 16, 2024

Uh, you lost me. What does `timeScale´ represent?

from cordova-plugin-media.

CVeniamin avatar CVeniamin commented on August 16, 2024

I also had trouble understanding timescale but think of it as Frames Per Second as this other StackOverflow response better explains.
avPlayer.currentItem.asset.duration is a structure which holds value and timescale when used both one is capable of computing the actual duration of a song.

from cordova-plugin-media.

CVeniamin avatar CVeniamin commented on August 16, 2024

Note there were some issues with the ionic webview where the local server was not providing range headers which caused seeking in a file to fail.

@ghenry22, this was the problem, when ionic webview served the files the range headers where not properly set hence the crash.
Has this issue been fixed since in ionic webview?

from cordova-plugin-media.

ghenry22 avatar ghenry22 commented on August 16, 2024

@CVeniamin it was fixed on iOS, not sure if it was ever an issue on Android. However, the very latest version of the plugin removes the build in webserver for iOS and uses special schema's instead. I haven't tested this most recent change yet personally.

from cordova-plugin-media.

CVeniamin avatar CVeniamin commented on August 16, 2024

@ghenry22, I also haven't updated cordova-plugin-ionic-webview because there are a few "breaking" changes, however I'll have too do it sooner than later.
I only experienced this problem on iOS because on android I do not use cordova-plugin-ionic-webview in combination with cordova-plugin-media.
Said that, I think it's adequate to close this issue hence it has been fixed for iOS.

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.