Flutter can't load File() from path on iOS - ios

Hey I am using flutter_sound package for voice recording.
But when I made a File() object from recorder file path, I have got not expected error on iOS when I am trying call length() or readBytes() functions..
on Android everything working fine, so I tried compare the made files on both platforms, and they are little bit different
ANDROID File path = /storage/emulated/0/...
iOS File path = file:///Users/kleinpetr/Library/Developer/......
I think the problem is in the different paths.
The error on iOS looks like this
Cannot retrieve length of file, path =
'file:///Users/kleinpetr/Library/Developer/CoreSimulator/Devices/62B6742D-0FA4-4B92-B138
0D9E717DB91B/data/Containers/Data/Application/8587EB31-CF5D-4045-950B
6C011AE3EA96/Library/Caches/voice-message.m4a' (OS Error: No such file or directory, errno = 2)

So using File.fromUri(Uri.parse(fullPath)) worked for you. What you're providing to File class isn't path actually, but URI string (it has protocol specified file:// in the beginning). What you have to do is to parse URI and create a File from it.

Related

Failed to Create Sound

Very simple issue but I have no idea if anyone can help me with it. Perhaps it is a bug? I simply want to load this order but get the warning that WARNING: C:\Users\Usuario\Documents\Corona Projects\BalloonTap\game.lua:259: audio.loadSound() failed to create sound 'audio/pop.wav´.
The directory of the audio of the audio file is C:\Users\Usuario\Documents\Corona Projects\BalloonTap\audio
The code is:
balloonPop = audio.loadSound( "audio/pop.wav")
Any possible fixes? I have tried different audio files and renaming file. I have tried putting it in the main folder and just saying balloonPop = audio.loadSound( "pop.wav") but that fails as well.
When sounds are not loading in Corona, it is a good idea to check that the file can be found:
local filename = "audio/pop.wav"
if system.pathForFile( filename , system.ResourceDirectory ) == nil then
print("WARNING: cannot find audio file "..filename )
end
The fact that the sound could not be created suggests, however, that this is not the problem. From the Audio Usage/Functions Guide:
Cross-platform .wav files must be 16-bit uncompressed.
Is your sound file in the correct format?

HTMLAudioElement Audio Not Playing on iOS (Ionic App)

I am using Xcode 8 and Ionic. I can get audio to play on Android but not iOS. The log from Xcode says this:
2016-07-13 18:19:44.802014 SpotShuffle[830:104683] [] <<<< FIGSANDBOX >>>> Path </private/var/mobile/Containers/Data/Application/EC634407-1752-4EE2-814E-B88353EA36B0/tmp/MediaCache> could not be converted by realpath() (requires all elements of path are present)
2016-07-13 18:19:44.803145 SpotShuffle[830:104683] [] __InternalSandboxRegisterURL_block_invoke signalled err=-12780 (kFigBaseObjectError_ParamErr) (Could not obtain realpath for specified URL) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMediaFramework/EmbeddedCoreMedia-1847.11.1/Prototypes/Player/ClientServer/FigSandboxSupport.c line 590
Do you have any advice?
I'm getting a similar error trying to play a video in iOS 10 beta 2.
"Could not obtain realpath for specified URL"
ObtainAndRegisterSandboxExtensionForPath signalled err=-12780 (kFigBaseObjectError_ParamErr) (Could not obtain realpath for specified URL) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMediaFramework/EmbeddedCoreMedia-1873/Prototypes/Player/ClientServer/FigSandboxSupport.c line 486
My guess is that somewhere in the file is a URL starting with "//:" instead of "http//:". Web browsers will pickup the right URL protocol from the pages URL. In Ionic and Cordova the page protocol is "file://", which might be breaking the realpath library.
try to covert your audio file to base64
mySound = new Audio("data:audio/mp3;base64,//uQBAAAAAA.... ..qq");
collectSound.play();
it may work. however it may open system player as well. need to find a way to keep the context of you app

Play downloaded Widevine Classic files from app document folder in iOS?

I am trying to play wvm files from the app documents folder since 3 days but without success...
I removed "file://" from my path but I still get 1013 error (as discussed here), does someone have some sample code or at least the procedure to follow to make it works properly?
WV_RegisterAsset(myFilePath) always return WViOsApiStatus(rawValue: 1013)
The file should exists because when I try this:
let fileManager = NSFileManager()
print(fileManager.fileExistsAtPath(myFilePath))
It returns true
Thanks in advance for your help!
Widevine Classic on iOS uses an "asset root" directory. When you initialize the library, you pass it in the settings dictionary using the key WVAssetRootKey.
After that, all local asset pathnames you pass to the library are relative to the AssetRoot.
One simple option is to use NSHomeDirectory() as the AssetRoot, and then trim it from the beginning of absolute pathnames.

Adding a new language to Tesseract ios SDK

I am able to compile the English version which is already in sample for tesseract but not able to add other language like swe.traineddata.
I'm doing like this
G8RecognitionOperation *operation = [[G8RecognitionOperation alloc] initWithLanguage:#"eng+swe"];
When adding this its giving this error but working fine with English.
Cube ERROR (CubeRecoContext::Load): unable to read cube language model params from /private/var/mobile/Containers/Bundle/Application/D93B654A-1E46-4A34-9A83-95C6FC903085/*.app/tessdata/swe.cube.lm
Cube ERROR (CubeRecoContext::Create): unable to init CubeRecoContext object
init_cube_objects(true, &tessdata_manager):Error:Assert failed:in file tessedit.cpp, line 203
The fact it does not work has to do with the engine mode. If you use the CubeOnly or TesseractCubeCombined, you need 'cube' files. Engine mode TesseractOnly works fine.
you are missing some of files,I think so.Also check on Create Folder References.that helped me once.

Audio files working in iOS simulator, but can't be found on actual device

When I run my app which plays sound in the iOS simulator, it works perfectly. However when I run it on my actual device, the following error appears:
2015-04-20 21:44:00.173 Practical11-1[230:7753] PAEAudioFilePlayer path:/private/var/mobile/Containers/Bundle/Application/D9E12F4A-88F6-41FC-9A0D-A195A56285DF/Practical11-1.app/sounds/rain.aif not found
The code I am using is to get the files is:
// An array of all available sounds
self.filenames = #[#"rain.aif",
#"storm.aif",
#"seaside.aif",
#"fire.aif",
#"nighttime.aif",
#"whitenoise.aif"];
and then:
if (index < 0 || index >= self.activeFilenames.count)
return;
// use the file name at the index to create the path
NSString* bundlePath = [#"sounds"stringByAppendingPathComponent:self.activeFilenames[index]];
Does anybody have any ideas?
I've had this issue before when the sound files where saved with a capital letter in my project and referenced in lowercase on my project. i.e:
The file in the project = Rain.aif
The file in the project = rain.aif
The simulator would be able to interpret the resource and find the right one but the device would fail due to case sensitivity.

Resources