Alert.play_file not working

A Ariana Habbaba 2 years 11 months ago
1 3 0

Hi all,

I'm trying to implement a function that will play an mp3 and a wav file
I've placed 2 files in the public folder of my application:
1. Bluesy_guitar.mp3
2. Space.wav

Here is the code I have implemented in my alert_controller.rb file

  def play_file1    @title = "play_file1"    Alert.play_file "Bluesy_guitar.mp3"    render :action => :index  end    def play_file2    @title = "play_file2"    Alert.play_file "Space.wav"    render :action => :index  end
Everytime I try running these methods, I keep getting this error in the log.txt file

RhoFileApi| Opening file from file system: /data/data/com.rhomobile.pimalerts/rhodata/apps/Bluesy_guitar.mp3RhoFileApi| Can not open file descriptor: /data/data/com.rhomobile.pimalerts/rhodata/apps/Bluesy_guitar.mp3: open failed: ENOENT (No such file or directory)Alert| Call of "playFile" failed: null
Not sure what's going wrong here.

I've tried putting
Alert.play_file "/public/Bluesy_guitar.mp3"
I've tried putting the entire path from the root to the file, but nothing's working.
I'm not sure where this path name came from either : /data/data/com.rhomobile.pimalerts/rhodata/apps/

I'd appreciate any kind of help.

Thanks,
Ariana

Please register or login to post a reply

3 Replies

M Marcus Atkins

Hi all,

Have got the alerts working, however I did run into a few issues:

1. Sound never played through the RhoSimulator
2. '/public/alerts/sound.mp3' path did not work (use Rho.RhoFile.join(Rho.RhoFile.join(Rho.Application.publicFolder, 'assets'), 'sound.mp3)))

The code to get the sound to play (in javascript):

function playSuccessAlert(){
  Rho.Notification.playFile(Rho.RhoFile.join(getAlertsLocation(), 'sound_success_alert.mp3'));
}

function getAlertsLocation(){
  return (Rho.RhoFile.join(Rho.Application.publicFolder, 'alerts'));
}

Hopefully this will help someone out in the future.

E Evgeny Vovchenko

http://docs.rhomobile.com/rhodes/device-caps#file-system-access

use get_public_folder()

File.join(Rho::RhoApplication::get_public_folder(), 'Bluesy_guitar.mp3')

A Ariana Habbaba

So what I did was replace
Alert.play_file "/public/Bluesy_guitar.mp3"
with
Alert.play_file File.join(Rho::RhoApplication::get_public_folder(), 'Bluesy_guitar.mp3')

And it's still giving me the same error:
Can not open file descriptor: /data/data/com.rhomobile.pimalerts/rhodata/apps/data/data/com.rhomobile.pimalerts/rhodata/apps/public/Bluesy_guitar.mp3: open failed: ENOENT (No such file or directory)

CONTACT
Can’t find what you’re looking for?