StopFcn not working with audioplayer object
显示 更早的评论
I'm using App Designer with the following code:
app.Player = audioplayer(y, Fs);
app.Player.StopFcn = @PlayerStoppedFcn;
function PlayerStoppedFcn(audioplayer, ~)
% do something
end
However, this error appears regarding the StopFcn callback...
Warning: Error occurred while executing the listener callback for event Custom defined for class asyncio.Channel:
Error using internal.Callback.execute (line 128)
Undefined function 'PlayerStoppedFcn' for input arguments of type 'audioplayer'.
> In asyncio.Channel/onCustomEvent (line 473)
In asyncio.Channel>@(source,data)obj.onCustomEvent(data.Type,data.Data) (line 405)
Can you help? Thanks in advance.
3 个评论
Geoff Hayes
2020-4-8
John - it isn't clear from the error message whether the PlayerStoppedFcn cannot be found or whether there is a problem with the input to it. Is this function in a separate m-file that can be found in the MATLAB search path? Or is it embedded somewhere in your App.
One recommendation is to change the function signature
function PlayerStoppedFcn(audioplayer, ~)
The first input parameter is named audioplayer which is the same name as the built-in MATLAB audio player object. Just change this to something diffferent so as not to conflict
function PlayerStoppedFcn(playerObject, ~)
(depending upon your version of MATLAG this could be the object or a handle to the audio player object).
John D
2020-4-8
John D
2020-4-8
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!