iOS Question No uncompressed .wav-files in AV-Player or other solution to play audio-file (wav) while creating it?

Cadenzo

Active Member
Licensed User
Longtime User
The AVplayer doesn't seem to play uncompressed .wav files. Nothing can be heard and my research shows only AAC or MP3 format. Too bad, I thought I had found a solution.

What I need is an audio player that already plays the beginning of a local file while more data is added to it in the background. Is this possible? Any ideas? The MediaPlayer plays the file but doesn't let append data to it anymore. Unfortunately I can't get any further here.

B4X:
Private Sub CreatePlayerAV(url As String) As NativeObject
    Dim u As NativeObject
    u = u.Initialize("NSURL").RunMethod("URLWithString:", Array(url))
    Dim player As NativeObject
    player = player.Initialize("AVPlayer").RunMethod("alloc", Null) _
     .RunMethod("initWithURL:", Array(u))
    Return player
End Sub

Dim sUrl As String = File.Combine(folder, filename)
playerAV = CreatePlayerAV(sUrl)
 

Cadenzo

Active Member
Licensed User
Longtime User
Thanks Erel, I tried this, but the MediaPlayer object seems not to accept appended data on the music that is already loaded while playing it (or I am doing something wrong here). The wave header needs the correct file size. I also tried to fill the later created data with zero and give the wave-header a larger file-sitze.

That's why I tried the AV-Player. But it does not accept wave-format :( Also okay would be a player, where I can stream the data while playing from memory (add short-arrays, as it is possible in B4A) But also here I did not find something in B4i.
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
Let me explain a bit more, what I am looking for and why. May be, someone has a good solution.
I have a song as list of MIDI-data. With this I create and play a wave-file with my own piano-wave-samples. This works, but it takes time, to create a wave-file. On iOS much more than on Android, about one minute creating for 8 minutes music.

So I wanted do do this:
1. -Create the first 4 seconds of the music
2. -Start playing the file
3. -create the rest while already playing

But the Player stops after the 4 seconds. So I think, it loads already the music into an intern buffer and the appended data has no effect.
 
Upvote 0
Top