[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to embedded file/sound into executable?


On 3/24/24 00:01, Admin wrote:
24.03.2024 10:04, T Lee Davidson пишет:
[snip]


Public Sub Main()

  Dim Data As Stream
  Dim pPlay As Process

  Data = Open "./din-din.wav" For Read
  pPlay = Exec ["aplay"] For Write

  Write #pPlay, Read #Data, Lof(Data)

End



Oh. That's interesting. Can we supply an image for dd this way? Can we monitor the progress?

Dmitry

`dd` can accept input from stdin, so, yes. But, you would not be able to monitor the progress while transferring the entire length of the stream on one line. You would need to transfer the data in chunks of a predetermined size, and be sure to not try reading past the end of the stream.

Public Sub Main()

  Dim Data As Stream
  Dim pPlay As Process
  Dim iDataSize, iProgressBytes As Integer
  Dim iChunkSize As Integer = 1024


  Data = Open "./din-din.wav" For Read
  pPlay = Exec ["aplay"] For Write

  iDataSize = Lof(Data)
  While Not Eof(Data)
    Write #pPlay, Read #Data, iChunkSize
    iProgressBytes += iChunkSize
    iChunkSize = Min(iChunkSize, iDataSize - iProgressBytes)
    Print Subst("&1 %", Format(iProgressBytes / iDataSize * 100, gb.Fixed))
  Wend

End



--
Lee

--- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
--- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----


Follow-Ups:
Re: How to embedded file/sound into executable?T Lee Davidson <t.lee.davidson@xxxxxxxxx>
References:
How to embedded file/sound into executable?roberto.premoli@xxxxxxxxxx
Re: How to embedded file/sound into executable?T Lee Davidson <t.lee.davidson@xxxxxxxxx>
Re: How to embedded file/sound into executable?roberto.premoli@xxxxxxxxxx
Re: How to embedded file/sound into executable?BB <adamnt42@xxxxxxxxx>
Re: How to embedded file/sound into executable?BB <adamnt42@xxxxxxxxx>
Re: How to embedded file/sound into executable?T Lee Davidson <t.lee.davidson@xxxxxxxxx>
Re: How to embedded file/sound into executable?Admin <admin@xxxxxxxxxx>