nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

Problem with playing remote file #62

Closed jibon57 closed 7 years ago

jibon57 commented 7 years ago

Hi,

Thanks for the plugin. I am trying to play remote file like this:

var audioPlayer = new TNSPlayer();
    audioPlayer.playFromUrl({
      audioFile: file,
      loop: false,
      completeCallback: function() {
        console.log("Completed !!")
      },
      errorCallback: function(err) {

      }
    })

But I am getting following error in IOS:

Jul 21 18:18:21 --- last message repeated 8 times ---
CONSOLE LOG file:///app/components/coursemodules/jibon/jibon.js:35:20: 7
CONSOLE ERROR file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:571:22: Error: Uncaught (in promise): undefined
1   0x10824415b NativeScript::FFICallback<NativeScript::ObjCBlockCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2   0x10893211e ffi_closure_unix64_inner
3   0x108932a52 ffi_closure_unix64
4   0x10c291095 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke
5   0x108f96237 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
6   0x108f95f3b -[NSBlockOperation main]
7   0x108f946f7 -[__NSOperationInternal _start:]
8   0x108f9047c __NSOQSchedule_f
9   0x10efa1792 _dispatch_client_callout
10  0x10ef87237 _dispatch_queue_serial_drain
11  0x10ef8798f _dispatch_queue_invoke
12  0x10ef89899 _dispatch_root_queue_drain
13  0x10ef8950d _dispatch_worker_thread3
14  0x10f32d5a2 _pthread_wqthread
15  0x10f32d07d start_wqthread
file:///app/tns_modules/nativescript-audio/src/ios/player.js:83:34: JS ERROR TypeError: null is not an object (evaluating '_this._player.delegate = _this')
Jul 21 18:18:22 Jibons-Pro SpringBoard[5014]: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focus
Jul 21 18:18:22 Jibons-Pro backboardd[5015]: [Common] Unable to get short BSD proc info for 9046: No such process
Jul 21 18:18:22 Jibons-Pro backboardd[5015]: [Common] Unable to get proc info for 9046: Undefined error: 0

Any idea, in where I am doing wrong?

Thanks

bradmartin commented 7 years ago

Did you ever figure it out @jibon57

zbarbuto commented 6 years ago

I'm currently also having this issue with a fresh project. It doesn't happen when running the demo project from this repo, though, so I'm assuming its a dependency issue.

bradmartin commented 6 years ago

Dependency or the file isn't compatible to be played from the native os media players. Got a link to the file you can share?

zbarbuto commented 6 years ago

The problem seems to be that initWithDataError does not actually return the player (for whatever reason) on iOS. FWIW this is a NativeScript Angular project. I'll setup an example repo for you in a minute.

zbarbuto commented 6 years ago

https://github.com/zbarbuto/nativescript-audio-62

zbarbuto commented 6 years ago

the file isn't compatible to be played from the native os media players.

I've used the same file as the demo project in my demo repo to rule that out.

bradmartin commented 6 years ago

@zbarbuto - have you tried waiting for the promise to resolve before calling play in this project? https://github.com/zbarbuto/nativescript-audio-62/blob/master/app/item/item-detail.component.ts#L23 that method returns a promise, I haven't ran the demo so if you can rule that out for me first I'll try to look at this later on and see if something is wrong with the audio plugin logic.

zbarbuto commented 6 years ago

The error is thrown on that line so it doesn't even get as far as play. You can comment out the play line and it will still throw the same rror.