Visual HMIオーディオ再生:Play_soundシリーズとMP 3自動接続

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

オーディオ再生API:SD/USBスティックから音楽ファイルを再生し、プレーヤーコントロールを使用して完全な音楽プレーヤーを作成します(再生/一時停止/トップ/トップ/プログレスバー/ボリューム)。

1. APIの概要

関数の機能説明書は
play_sound(filename)オーディオの再生、绝対パス“1/mu/xx.3”など
stop_sound()演奏をStop。
pause_sound()サスペンションサスペンション。
resume_sound()放送を続ける。

2.プレーヤコントロールアドレステーブル

アドレス:address目的は
LW1000ページをめくる。
LW1001Previous/Nextの記事
LW1002再生/一時停止(ビットステータスLED:0-一時停止/1-継続)
LW1003現在のページ
LW1004総ページ数
LW1005SDルートに歌があるかどうか(ビット状態)
LW1100~1200曲のタイトル一覧
LW1240現在の時間を再生
LW1250合計時間。
LW1006進行状況バーの再生
LW0140Volume Volume

3. SDカードの曲

musicList = {}      --曲名リストキャッシュ
PlayIndex = 1

function on__inserted dir
  list_dir dir           --列 SDカーガンディレクトリ
End of Endシングル

function on_list_dir path、、type、fsize
  型== 1の場合
    local ext = string.sub filename-4
    if ext === ". 3" or ext == ". w" then
      table.insert musicNameListTb filename
      set_uint16 VT_LW、0x1005,1   歌のサインがあります。
    End of Endシングル
  End of Endシングル
End of Endシングル

4.制御ロジックの再生

function on_update slave vtype
  if vtype ==_LW then
    addr === 0 x 100 2の場合
      local v = get_uint16 VT_LW、0x1002
      v == 1ならば
        play_sound "1/mu/"... musicList [PlayIndex]
      elseさん
        pause_sound
      End of Endシングル
    elseif addr === 0 x 1001 then
      --前/次:curPlayIndexを切り替えて再生
      local v = get_uint16 VT_LW、0x1001
      v === 1とcurPlayInde x 1の場合
        PlayIndex =
      elseif v == 2 and curPlayInde x #musicNameListTb then
        curPlayIndex = curPlayIndex + 1
      End of Endシングル
      play_sound 1/mu/... musicList [PlayIndex]
    End of Endシングル
  End of Endシングル
End of Endシングル

function on_run screen
  updatMisPlayState     - 再生状態を検出し、自動的に次の曲を再生する
End of Endシングル
3つの穴パスにはデバイスプレフィックスが必要です。Mシリーズ1②再生後は自動的にカットしないon_runで再生ステータスをポーリングします(on_video_notifyと同様のメカニズム)。ファームウェアサポートリストに基づくオーディオフォーマットサポートされていないフォーマットはサイレントに失敗します。最初にブロードキャストできるファイルを試してください。

Guangzhou Dai Cai Technology Visual HMI開発ドキュメント(hmi-doc.gz-dc.com)LUAチュートリアル“オーディオ再生”、著作権はDai Cai Technologyにあります。

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.