Cannot set an encrypted multifile as the global mount


#1

Greetings. I’m trying to set my game’s global mount to a multifile which is encrypted but it doesn’t seem to work correctly As I always get errors regarding that it couldn’t load an audio file in a folder with the same name as my multifile, next to my main .py file. I know what this is. It is trying to load the audio file from a folder with the same name as the multifile after it failed to load it from the multifile itself. But here’s the thing. First of all, I’m able to mount the file without any problems when the multifile isn’t encrypted. As soon as I replace the multifile with an encrypted version of it, These errors pop up and no audio plays at all. Second, I can extract the said audio file by opening the multifile as openRead, then setting the encryptionFlag to True, and setting the encryptionPassword to whatever the password is set when I was packing the multifile and then calling Multifile.extractSubfile(NumberOfSubfile, WhereToExtract). This works fine and I can even play the extracted audio with my generic media player.
The problem seems to show up when I’m trying to mount the multifile as the global mount.
The following lines contain the related code to my problem:

from panda3d.core import VirtualFileSystem, Multifile, Filename
#the following lines are inside my class.
		self.sounds=Multifile()
		self.sounds.openRead('sounds.mf')
		self.sounds.setEncryptionFlag(True)
		self.sounds.setEncryptionPassword("password")
		self.vfs=VirtualFileSystem.getGlobalPtr()
		print("loading. Please wait... ")
		if self.vfs.mount("sounds.mf", "sounds", VirtualFileSystem.MF_read_only, "password"):
			auto.speak("Done")
			
			self.sounds.extractSubfile(2, Filename(self.sounds.getSubfileName(2)))

I’m using audio3DManager to play my audio files.
Thanks for reading


#2

What audio file format are you using? From my experience I know that you can’t encrypt “ogg”, but you can encrypt “wav”. I haven’t tried others.


#3

I have yet to try this myself, but it sounds like the problem might be that encrypted or compressed audio streams are not seekable, and audio codecs often like to work with seekable streams.

The wav reader indeed supports non-seekable streams, but as a result you can only seek forward in such a wav file. If the files are in Ogg Vorbis format, it might be worth a try to set vorbis-enable-seek false in Config.prc to see if that allows you to load the .ogg file anyway, though seeking will not be possible.