I am re-posting this now that I have a simple sample of the problem.
I am writing an app that lets you save Images and audio in the Documents Directory. I am having problems with both images and audio.
I save an image in one scene and proceed to read it in a different scene. I get a warning that the file is not there. When I look at the sandbox, the image is there
The problem only occurs when using display.save() or media.newRecording() to write the data to a file, it does not come about when I use object:write.
I wrote a sample code that shows the problem.
main.lua:
[lua]local storyboard = require( “storyboard” )
display.setStatusBar(display.HiddenStatusBar)
– load starting screen
storyboard.gotoScene( “addimg”)[/lua]
addimg.lua:
[lua]local widget = require “widget”
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local _X = display.viewableContentWidth; _Y = display.viewableContentHeight
local saveBtn, image
local function onSaveBtnRelease()
storyboard.removeScene(“addphoto”)
storyboard.gotoScene(“addphoto”, “fromRight”)
end
function scene:createScene( event )
addimgGroup = self.view
saveBtn = widget.newButton{
defaultFile=“Save.png”,
overFile=“Saveovr.png”,
width=120, height=120,
onRelease = onSaveBtnRelease – event listener function
}
saveBtn.x =_X * 0.5
saveBtn.y = _Y * 0.5
saveBtn.isVisible = false
addimgGroup:insert(saveBtn)
image = display.newImageRect(“maze01.jpg”, 400, 300)
image.isVisible = false
addimgGroup:insert(saveBtn)
end
function scene:enterScene( event )
saveBtn.isVisible = true
image.isVisible = true
addimgGroup:insert(saveBtn)
local i = 3
display.save( image,“myImage”…i…".jpg", system.DocumentsDirectory )
end
function scene:exitScene( event )
display.remove (saveBtn)
display.remove (image)
saveBtn = nil
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene )
end
function scene:destroyScene( event )
display.remove (saveBtn)
display.remove (image)
saveBtn = nil
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene)
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene[/lua]
addphoto.lua:
[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
function scene:createScene( event )
addphotoGroup = self.view
local i =3
local imagePath = system.pathForFile( “myImage”…i…".jpg", system.DocumentsDirectory )
local image = display.newImageRect(imagePath, 864, 648)
image.isVisible = false
addphotoGroup:insert(image)
end
function scene:enterScene( event )
image.isVisible = true
end
function scene:exitScene( event )
display.remove (image)
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene )
end
function scene:destroyScene( event )
display.remove (image)
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene)
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene[/lua]
Am I doing something wrong or should I report a bug?
Bill