StopFcn not working with audioplayer object

3 ビュー (過去 30 日間)
John D
John D 2020 年 4 月 7 日
コメント済み: John D 2020 年 4 月 8 日
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 件のコメント
John D
John D 2020 年 4 月 8 日
Unfortunately, changing the name of 'audioplayer' didn't work.
The PlayerStoppedFcn is placed like so:
function PlayerStoppedFcn(obj, ~)
disp("Something");
end
function playaudio(app)
[y, Fs] = audioread("filename.wav");
app.Player = audioplayer(y, Fs);
app.Player.StopFcn = @PlayerStoppedFcn;
play(app.Player);
end
The playaudio(app) function is called from a UI control callback.
Hope this helps.
John D
John D 2020 年 4 月 8 日
After looking at it again, the following seems to work:
app.Player.StopFcn = createCallbackFcn(app, @PlayerStoppedFcn, true);
Thanks for your help nonetheless.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by