Help with retrieving recorded audio file from system.DocumentsDirectory

Hi there!  I need help with retrieving a recorded audio file from system.DocumentsDirectory in my code.  I record an audio file in corona, then I save it to system.DocumentsDirectory.  I need to access this audio file within a OneSignal push notification Post.  

The audio is recorded and plays back fine.  But when the push notification is called when i press btn3, the notification appears but without the recorded audio file that should play.

All help is appreciated thanks!

code below: 

[lua] 

– Your code here

local OneSignal = require(“plugin.OneSignal”)

– This function gets called when the user opens a notification or one is received when the app is open and active.

– Change the code below to fit your app’s needs.

function DidReceiveRemoteNotification(message, additionalData, isActive)

    if (additionalData) then

        if (additionalData.discount) then

            native.showAlert( “Discount!”, message, { “OK” } )

            – Take user to your app store

        elseif (additionalData.actionSelected) then – Interactive notification button pressed

            native.showAlert(“Button Pressed!”, “ButtonID:” … additionalData.actionSelected, { “OK”} )

        end

    else

        native.showAlert(“OneSignal Message”, message, { “OK” } )

    end

end

OneSignal.Init(“MY ONE SIGNAL ID GOES HERE”, “############”, DidReceiveRemoteNotification)

– Creates a notification to be deliver to this device as a test.

function IdsAvailable(userID, pushToken)

    if (pushToken) then

        local notification = {

            [“contents”] = {[“en”] = “This is a Test notification! HI MAX!!”, [“ios_sound”] = “newRecording.aif”}

    

        }

        

        notification[“include_player_ids”] = {userID}

        

        OneSignal.PostNotification(notification)

        

        

    end

end

local bg = display.newRect(display.contentCenterX, display.contentCenterY, 1000, 1000)

local btn1 = display.newCircle(display.contentCenterX, display.contentCenterY, 50)

btn1:setFillColor(1, 0, 0)

local btn2 = display.newCircle(display.contentCenterX, display.contentCenterY - 150, 50)

btn2:setFillColor(0, 1, 0)

local btn3 = display.newCircle(display.contentCenterX, display.contentCenterY + 150, 50)

btn3:setFillColor(0, 0, 1)

local function startRecording(event)

if (event.phase == “began”) then 

local filePath = system.pathForFile( “newRecording.aif”, system.DocumentsDirectory )

local recording = media.newRecording( filePath )

recording:startRecording()

end

end

local function stopRecording(event)

if (event.phase == “began”) then 

local filePath = system.pathForFile( “newRecording.aif”, system.DocumentsDirectory)

local recording = media.newRecording( filePath )

recording:stopRecording()

local sound = audio.loadSound(“newRecording.aif”, system.DocumentsDirectory )

audio.play(sound)

end

end

local function sendRecording(event)

if (event.phase == “began”) then

OneSignal.IdsAvailableCallback(IdsAvailable)

end

end

btn3:addEventListener(“touch”, sendRecording)

btn2:addEventListener(“touch”, startRecording )

btn1:addEventListener(“touch”, stopRecording ) [/lua]

Just throwing this out there… Mods really don’t like when people double post… Here is your second post.

https://forums.coronalabs.com/topic/60559-help-with-retrieving-recorded-audio-file-from-systemdocumentsdirectory/

–SonicX278

@SonicX278

Which post should I keep up?

@SonicX278 

Also do you have any idea on how to solve my problem?  I need a way to access an audio file that is put into the System.DocumentsDicrectory.  thanks

I’d keep this one as you’ll probably get help faster. Id help but iv’e never recorded audio before so i’m not sure where to start. Im sure you’ll get help fast. But i will take a look at your problem.

–SonicX278

@SonicX278

Thanks for looking at my problem.  The problem  doesn’t have to do with the audio.  It mainly has to do with accessing and retrieving a file from the documents directory.

BUMP

Just throwing this out there… Mods really don’t like when people double post… Here is your second post.

https://forums.coronalabs.com/topic/60559-help-with-retrieving-recorded-audio-file-from-systemdocumentsdirectory/

–SonicX278

@SonicX278

Which post should I keep up?

@SonicX278 

Also do you have any idea on how to solve my problem?  I need a way to access an audio file that is put into the System.DocumentsDicrectory.  thanks

I’d keep this one as you’ll probably get help faster. Id help but iv’e never recorded audio before so i’m not sure where to start. Im sure you’ll get help fast. But i will take a look at your problem.

–SonicX278

@SonicX278

Thanks for looking at my problem.  The problem  doesn’t have to do with the audio.  It mainly has to do with accessing and retrieving a file from the documents directory.

BUMP