Hi, Greeting
I am very new to Roku development. Currently I am researching to use remote mic to record the user commands by using roMicrophone;
My code like this:
mic = createObject(“roMicrophone”)
print mic.CanRecord()
mic.StartRecording()
In debug, canRecord() return true, but the error is given when I call StartRecoridng()
BRIGHTSCRIPT: ERROR: roMicrophone.StartRecording: message port not set: pkg:/components/dialogscene.brs(25)
But in main.brs , I have already add message port such as
screen = CreateObject(“roSGScreen”)
m.port = CreateObject(“roMessagePort”)
screen.setMessagePort(m.port)
Does anybody have the clue why it happens? and please let me know where I am wrong in using this component.
thanks
Alading
I haven’t used it (didn’t even know it existed), but you need to set a message port on the roMicrophone object: mic.SetMessagePort(m.port)
-JT
HI, JT
Thanks for your kindly help. I add code
mic = createObject(“roMicrophone”)
print mic.CanRecord()
mic.SetMessagePort(m.port)
mic.StartRecording()
But it still reports the error
BRIGHTSCRIPT: ERROR: roMicrophone.StartRecording: message port not set:
Any clue? thanks
Alading
I played with this for a little while and had minimal success. I’m not sure it’s worth pursuing. I was able to use RecordToFile to record short clips, but most times it recorded nothing and when it did record something it was very short (a second or less) and just cut off whenever it wanted to. I was able to receive events sometimes, but I never looked at the data.
What is the result of your “print mic.CanRecord()”? Sometimes I would get false and I think I’d have to reboot to get it back to returning true. Since m has different uses, you might want to create a message port just for your testing:
mic = createObject("roMicrophone")
print mic.CanRecord() ' <- better print true or there's no sense in continuing
port = CreateObject("roMessagePort")
mic.SetMessagePort(port)
mic.StartRecording()
-JT
It works and I received some event when I start recording even sometimes it still works as expected.
Thanks, JT. Let me know if I need to accept the answer or anything to help you promote your level as I am new in the Forum.