Page 1 of 1

How to use SampleImport ogg?

Posted: Tue Apr 22, 2025 10:24 pm
by Ats
I've been trying to test ZPlatform_Android.pas ReadAssetFile on Android, but I'm stuck.

ReadAssetFile is specific to Android and is called by Platform_ReadFile.
Which is used by ZClasses.pas TZInputStream.CreateFromFile

So in the end, I was trying to read an ogg file. And I'm a bit stuck. Is that how it works?

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ogg reader" FileVersion="2">
  <OnLoaded>
    <PlaySound Sound="SoundOGG"/>
  </OnLoaded>
  <Content>
    <Sample Name="SampleOGG" Length="INF">
      <Producers>
        <SampleImport Comment="Imported from file_example_OOG_1MG.ogg" SampleFormat="1" SampleFileFormat="1"/>
      </Producers>
    </Sample>
    <Sound Name="SoundOGG" Sample="SampleOGG"/>
  </Content>
</ZApplication>
I downloaded the ogg from here: https://file-examples.com/index.php/sam ... -download/
But when I import it, the Sample.length is INF
And the ogg sound isn't playing.

What am I doing wrong?

Re: How to use SampleImport ogg?

Posted: Wed Apr 23, 2025 8:27 am
by VilleK
See attached example for how to play an ogg file.

However the SampleImport only plays embedded files so it does not use ReadAssetFile.Try an example that uses the File component.