This shows you the differences between two versions of the page.
sample_code:view_sys_files [2015/09/23 12:30] stevegarman created |
sample_code:view_sys_files [2015/09/24 14:16] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== View Sys files ==== | ||
- | This code will display the image and sound files available in "/ | ||
- | ===== The code ===== | ||
- | |||
- | <code JavaScript sysFiles.js> | ||
- | var arr=["/ | ||
- | // | ||
- | function OnStart() | ||
- | { | ||
- | app.EnableBackKey(false); | ||
- | // | ||
- | lay = app.CreateLayout( " | ||
- | |||
- | player = app.CreateMediaPlayer(); | ||
- | player.SetOnReady(playerReady); | ||
- | // | ||
- | lst = app.CreateList( arr ); | ||
- | lst.SetOnTouch(lstOnTouch); | ||
- | lst.SetPosition(0, | ||
- | lay.AddChild( lst ); | ||
- | |||
- | // | ||
- | app.AddLayout( lay ); | ||
- | |||
- | lay2=app.CreateLayout(" | ||
- | lay2.SetBackColor("# | ||
- | lay2.SetBackground("/ | ||
- | img=app.CreateImage(null, | ||
- | img.SetOnTouchUp(imgOnTouch); | ||
- | lay2.AddChild(img); | ||
- | lay2.SetVisibility(" | ||
- | app.AddLayout(lay2); | ||
- | } | ||
- | |||
- | function lstOnTouch(item) | ||
- | { | ||
- | if(!app.FileExists(item)) return | ||
- | var three=item.slice(-3) | ||
- | if (three==" | ||
- | { | ||
- | var pic = app.CreateImage(item); | ||
- | img.Clear(); | ||
- | img.DrawImage(pic, | ||
- | lay2.Animate(" | ||
- | } | ||
- | if (three==" | ||
- | { | ||
- | player.SetFile(item); | ||
- | player.SeekTo(0); | ||
- | player.Play(); | ||
- | } | ||
- | } | ||
- | |||
- | function imgOnTouch() | ||
- | { | ||
- | lay2.Animate(" | ||
- | } | ||
- | function playerReady() | ||
- | { | ||
- | player.SeekTo(0); | ||
- | player.Play(); | ||
- | } | ||
- | |||
- | function OnBack() | ||
- | { | ||
- | if(lay2.GetVisibility()==" | ||
- | lay2.Animate(" | ||
- | else if(confirm(" | ||
- | } | ||
- | |||
- | </ |