Android SDK 媒体记录器。状态4

发布于 2025-01-05 08:04:48 字数 213 浏览 1 评论 0原文

我刚刚完成开发一个快速的 Android 应用程序。

小问题。什么是状态4?

我正在使用 MediaPlayer,每次运行该应用程序时都会收到一条错误消息,指出媒体播放器“start()”首先在状态 0 中调用,然后在状态 4 中调用。

有谁知道状态 4 是什么?

如果我知道状态 1 和 2 等状态,我就可以解决问题...

谢谢,

I'm just at the end of developing a quick Android App.

Minor problem. What's state 4?

I'm using MediaPlayer and every time I run the app I get an error stating that Media Player "start()" is first called in state 0, then state 4.

Does anyone know what state 4 is?

I can figure out the problem if I know the states such as state 1 and 2...

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏尔 2025-01-12 08:04:48

这是来自 Android 源代码中的 MediaPlayer.h:

enum media_player_states {
  MEDIA_PLAYER_STATE_ERROR        = 0,
  MEDIA_PLAYER_IDLE               = 1 << 0,
  MEDIA_PLAYER_INITIALIZED        = 1 << 1,
  MEDIA_PLAYER_PREPARING          = 1 << 2,
  MEDIA_PLAYER_PREPARED           = 1 << 3,
  MEDIA_PLAYER_DECODED            = 1 << 4,
  MEDIA_PLAYER_STARTED            = 1 << 5,
  MEDIA_PLAYER_PAUSED             = 1 << 6,
  MEDIA_PLAYER_STOPPED            = 1 << 7,
  MEDIA_PLAYER_PLAYBACK_COMPLETE  = 1 << 8
};

因此 0 将是 MEDIA_PLAYER_STATE_ERROR,4 将是 MEDIA_PLAYER_PREPARING。
在调用 start() 之前您是否调用了prepare() 或prepareAsync() ?

这些是 MediaRecorder 状态:

enum media_recorder_states {
  MEDIA_RECORDER_ERROR                 =      0,
  MEDIA_RECORDER_IDLE                  = 1 << 0,
  MEDIA_RECORDER_INITIALIZED           = 1 << 1,
  MEDIA_RECORDER_DATASOURCE_CONFIGURED = 1 << 2,
  MEDIA_RECORDER_PREPARED              = 1 << 3,
  MEDIA_RECORDER_RECORDING             = 1 << 4,
};

因此,对于录制,状态 4 是 MEDIA_RECORDER_DATASOURCE_CONFIGURED。

This is from MediaPlayer.h in the Android source:

enum media_player_states {
  MEDIA_PLAYER_STATE_ERROR        = 0,
  MEDIA_PLAYER_IDLE               = 1 << 0,
  MEDIA_PLAYER_INITIALIZED        = 1 << 1,
  MEDIA_PLAYER_PREPARING          = 1 << 2,
  MEDIA_PLAYER_PREPARED           = 1 << 3,
  MEDIA_PLAYER_DECODED            = 1 << 4,
  MEDIA_PLAYER_STARTED            = 1 << 5,
  MEDIA_PLAYER_PAUSED             = 1 << 6,
  MEDIA_PLAYER_STOPPED            = 1 << 7,
  MEDIA_PLAYER_PLAYBACK_COMPLETE  = 1 << 8
};

Therefore 0 would be MEDIA_PLAYER_STATE_ERROR and 4 would be MEDIA_PLAYER_PREPARING.
Did you call prepare() or prepareAsync() before calling start()?

These are the MediaRecorder states:

enum media_recorder_states {
  MEDIA_RECORDER_ERROR                 =      0,
  MEDIA_RECORDER_IDLE                  = 1 << 0,
  MEDIA_RECORDER_INITIALIZED           = 1 << 1,
  MEDIA_RECORDER_DATASOURCE_CONFIGURED = 1 << 2,
  MEDIA_RECORDER_PREPARED              = 1 << 3,
  MEDIA_RECORDER_RECORDING             = 1 << 4,
};

So for recording, state 4 is MEDIA_RECORDER_DATASOURCE_CONFIGURED.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文