1

i'm using the Cordova media object referenced here in IOS:

http://cordova.apache.org/docs/en/2.5.0/cordova_media_media.md.html#Media

On an android device it works perfectly, loads within seconds. But on a IOS device it takes sometimes more than a minute. Next to that my device becomes allmost non-responsive.

In the console I get this notification:

 void SendDelegateMessage(NSInvocation *): delegate (webView:resource:didFinishLoadingFromDataSource:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

I've mentioned that its not realy streaming, but just loads the complete file onto the device. Is there a way to solve this problem? Using Cordova 2.5.0

Martijn Mellens
  • 520
  • 7
  • 25

1 Answers1

1

What happens is that cordova, first download the file before running it, what I did was to change the method prepareToPlay of (CDVSound.m), using NSURLConnection to download the file and to run CFRunLoopRun (), which allowed me to display loding icon to the user, not solved the problem but I worked for me.

NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];

if (theConnection) {
  receivedData = [NSMutableData data];
  CFRunLoopRun();
} else {
 // Inform the user that the connection failed.
 }



- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

  // This returns control to wherever you called
  // CFRunLoopRun() from, so you can still clean up
  // or do other interesting things.
    NSLog(@"Termina de cargar...");
    CFRunLoopStop(CFRunLoopGetCurrent());

 }

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    NSLog(@"Error: %@", error);
    CFRunLoopStop(CFRunLoopGetCurrent());
  }
kvillaros
  • 41
  • 3