Problem with Mediaplayer

229 views
Skip to first unread message

Timo Octazid

unread,
Dec 9, 2014, 1:51:29 PM12/9/14
to androi...@googlegroups.com
Hi,
Could it be, that the method app.CreateMediaPlayer() has a bug?
A created Mediaplayer did not play .ogg-files from the path "/system/media/audio/ui/"
If I copy a file to another folder on "/sdcard/..." it plays the file.

Many Greetings
Timo

Steve Garman

unread,
Dec 9, 2014, 4:19:41 PM12/9/14
to androi...@googlegroups.com
I don't know if it's a bug but I see the same behaviour. My test code is:


//Called when application is started. 
function OnStart() 
{    
    //Create layout that fills the screen. 
    lay = app.CreateLayout( "Linear", "FillXY,VCenter" ); 
         
    //Create 'Play' button. 
    btn = app.CreateButton( "Play", 0.4, 0.1 ); 
    btn.SetOnTouch( btn_OnTouch ); 
    lay.AddChild( btn );  
     
    //Add main layout to app. 
    app.AddLayout( lay ); 
     
    //Create media player. 
    player = app.CreateMediaPlayer(); 
     
    //Load a file (can be ogg or mp3). 
    player.SetFile( "/system/media/audio/ui/Undock.ogg" ); 


//Handle 'Play' button. 
function btn_OnTouch() 

    player.SeekTo( 0 ); 
    player.Play(); 




Steve Garman

unread,
Dec 9, 2014, 4:31:36 PM12/9/14
to androi...@googlegroups.com
It doesn't seem to be a mediaplayer problem. We don't seem to have access to those files at all.

alert(app.FolderExists( "/system" ));

displays "false"

Dave Smart

unread,
Dec 9, 2014, 6:14:15 PM12/9/14
to androi...@googlegroups.com
That's because the /System folder does not exist. If you put a slash at the start then it's not a relative path. DroidScript will look for a root file system called 'System' and not find one.

Take off the slash at the front and it should be ok, assuming you have a sub folder below your project called 'system'.

Steve Garman

unread,
Dec 9, 2014, 10:57:47 PM12/9/14
to androi...@googlegroups.com
According to my file manager (Es), that path does exist as an absolute path. I can navigate to it on my hudl1 from "/"

It isn't one I created, it came with Android. I was not even aware of it till I saw this thread.

/system/media/audio contains sub folders for alarms, ringtones, notifications and ui.


Steve Garman

unread,
Dec 10, 2014, 2:36:12 AM12/10/14
to androi...@googlegroups.com
Dave,
I can persuade DroidScript to admit the existence of /system

alert( app.ListFolder("/").indexOf("system") );
// this displays "15"

but DroidScript won't let me get close enough to it to prove it is a directory.

It is not all root folders, app.ListFolder("/mnt") works fine, so does /etc.

There is a real folder "/sys" as well and DroidScript won't let me at it.
I wonder if that is a clue.

Dave Smart

unread,
Dec 10, 2014, 5:47:45 AM12/10/14
to androi...@googlegroups.com
Sorry Guys, I thought that you were accessing a sub folder of your project called 'system'.  

Now that I realize you mean a root folder called "/system" I can see the problem in DroidScript.  The problem is that I check for "/Sys" paths which map to internal DroidScript assets normally.  I can easily fix this by checking for "/Sys/" instead, but you will have to wait till the next release or next private beta release for a fix.

Regards
David

Aoide Aoede

unread,
Dec 10, 2014, 11:36:44 AM12/10/14
to androi...@googlegroups.com
Using a terminal *) and the shell ( ls -l / ) one can see that the /system and /sys folders are read-only, except to their owner root. 

It may be that the app.CreateMediaPlayer().SetFile() and app.FolderExists() functions expect full (read and write) access for some reason.

*) E.g. 
https://play.google.com/store/apps/details?id=jackpal.androidterm
Reply all
Reply to author
Forward
0 new messages