Send Message to Livecode from LCB Library

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
Gurgen
Posts: 34
Joined: Thu Dec 10, 2015 2:09 pm

Send Message to Livecode from LCB Library

Post by Gurgen » Tue Jan 09, 2018 9:34 am

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

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: Send Message to Livecode from LCB Library

Post by LCMark » Tue Jan 09, 2018 9:45 am

@gurgen: I think this is what you are looking for - https://github.com/livecode/livecode/pull/6063 - this should be in dp-11 :)

Gurgen
Posts: 34
Joined: Thu Dec 10, 2015 2:09 pm

Re: Send Message to Livecode from LCB Library

Post by Gurgen » Tue Jan 09, 2018 3:28 pm

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

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 192
Joined: Thu Apr 18, 2013 2:48 pm

Re: Send Message to Livecode from LCB Library

Post by livecodeali » Tue Jan 16, 2018 2:26 pm

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.

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 192
Joined: Thu Apr 18, 2013 2:48 pm

Re: Send Message to Livecode from LCB Library

Post by livecodeali » Tue Jan 16, 2018 2:30 pm

Ha, looks like I already filed it.
http://quality.livecode.com/show_bug.cgi?id=19868

Post Reply

Return to “LiveCode Builder”