Page 1 of 1

Send Message to Livecode from LCB Library

Posted: Tue Jan 09, 2018 9:34 am
by Gurgen
Hi All,

I'm trying to little modify the built in Android Background Audio Player to send callback when the audio is finished.

I know there is function SendToScriptObject which is something what I'm looking for, but this only works on widget libraries. Is there any other function to send message to Livecode from LCB external Library?

Any help will be highly appreciated.

Thanks,
Gurgen

Re: Send Message to Livecode from LCB Library

Posted: Tue Jan 09, 2018 9:45 am
by LCMark
@gurgen: I think this is what you are looking for - https://github.com/livecode/livecode/pull/6063 - this should be in dp-11 :)

Re: Send Message to Livecode from LCB Library

Posted: Tue Jan 09, 2018 3:28 pm
by Gurgen
Thanks Mark,

For some reason this syntax is working on example bellow:

Code: Select all

public handler NotifyMe() returns nothing
	post "playerFinished" to the caller
end handler
But is not working here :

Code: Select all

private handler bgaudioOnFinish(in pContext as JObject) returns nothing
	mediaplayerStop()
	put nothing into mContext
	put nothing into mPendingAudio

	post "playerFinished"
end handler
I assume the callbacks are not executed (I may be wrong).


Thanks for great support,

Gurgen

Re: Send Message to Livecode from LCB Library

Posted: Tue Jan 16, 2018 2:26 pm
by livecodeali
Hi Gurgen - you're missing a call to `MCEngineRunloopBreakWait()` after the `post` - this wakes up the engine thread. I'll file a bug as this should probably just happen behind the scenes without having to call it explicitly.

Let me know if that fixes your problem.

Re: Send Message to Livecode from LCB Library

Posted: Tue Jan 16, 2018 2:30 pm
by livecodeali
Ha, looks like I already filed it.
http://quality.livecode.com/show_bug.cgi?id=19868