Sync Audio&Text
TODO
the latest model defaults.sync has audioProps and textProps but UI does not have them yet
update page3/layers
- alphabet_sync.lua,
- iamacat_sync.lua
- mynameiskwik_sync.lua
props.text –> props.line
props.languge –> props.line.en, props.line.jp and textProps.language = {“en”, “jp”}
UI

default
local M = {
name = "alphabet",
class = "sync",
controls = {
autoPlay = true,
delay = nil,
fadeDuration = 1000,
speakerIcon = true,
wordTouch = true,
},
audioProps = {
filename = "alphabet.mp3",
channel = 2,
volume = 10,
},
textProps = {
folder = nil,
font = nil1,
fontColor = { 1,1,1 },
fontColorHi = { 1, 1, 0 },
fontSize = 36,
language = nil,
padding = 10,
readDir = "leftToRight",
sentenceDir = "alphabet", -- wordTouch
}
}
M.line = {
{ start = 0, out = 1000, dur = 0, name = "A", file = "a.mp3", action = "onComplete"},
{ start = 1000, out = 2000, dur = 0, name = "B", file = "b.mp3", action = "onComplete"},
{ start = 2000, out = 3000, dur = 0, name = "C", file = "c.mp3", action = "onComplete"},
}
Sync Audio & Text
test/base-proj/Solar2D/App/bookFree/components/page3/index.lua
local sceneName = ...
--
local scene = require('controller.scene').new(sceneName, {
name = "page3",
components = {
layers = {
{ test={}},
{ alphabet = {class={"sync"}}},
{ iamacat = {class={"sync"}}},
{ mynameiskwik = {class={"sync"}}},
},
audios = {
long = {"GentleRain", "Tranquility" },
short ={"ballsCollision"} ,
},
groups = {},
timers = {},
variables = {},
page = { }
},
commands = { "onComplete", "play" },
onInit = function(scene) print("onInit") end
})
--
return scene
files(mp3 and text) are structeud in the following patterns A-D. See the examples of sync audio text in page3/index.lua
A: alphabet
not multi-lingual
word touch enabled and files are in alphabet folder
clicking a word in a line, the word.mp3 is played
── sync ├── alphabet │ ├── a.mp3 │ ├── b.mp3 │ └── c.mp3 ├── alphabet.mp3 ├── alphabet.txt
B: iamcat
- en and jp
- word touch enabeld and mp3 files of words are in i_am_cat folder
── sync ├── en │ ├── i_am_a_cat │ │ ├── am.mp3 │ │ ├── cat.mp3 │ │ └── i.mp3 │ ├── i_am_a_cat.mp3 │ ├── i_am_a_cat.txt └── jp ├── i_am_a_cat │ ├── am.mp3 │ ├── cat.mp3 │ └── i.mp3 ├── i_am_a_cat..txt ├── i_am_a_cat.mp3
C: mynameiskwik
- en and jp
- mp3 and txt are in page3 folder
- no word touch
── sync ├── en │ └── page3 │ ├── my_name_is_kwik.mp3 │ └── my_name_is_kwik.txt └── jp └── page3 ├── my_name_is_kwik.mp3 └── my_name_is_kwik.txt
- en and jp
D: my father is nice
- en and jp
- no word touch
── sync ├── en │ ├── my_father_is_nice.mp3 │ ├── my_father_is_nice.txt └── jp ├── my_father_is_nice.mp3 ├── my_father_is_nice.txt
A: alphabet
local props = {
name = "alphabet",
filename = "alphabet.mp3",
type = "sync",
autoPlay = true,
channel = 2,
folder = nil
}
props.text = {
{ start = 0, out = 1000, dur = 0, name = "A", file = "a.mp3", action = "onComplete"},
{ start = 1000, out = 2000, dur = 0, name = "B", file = "b.mp3", action = "onComplete"},
{ start = 2000, out = 3000, dur = 0, name = "C", file = "c.mp3", action = "onComplete"},
}
props.wordTouch = true
props.sentenceDir = "alphabet" -- wordTouch
props.layer = "alphabet"
B: i am cat
local props = {
name = "i_am_a_cat",
filename = "i_am_a_cat.mp3",
type = "sync",
language = {},
autoPlay = true,
channel = 2,
folder = nil
}
props.language.en = {
{ start = 0, out = 500, dur = 0, name = "I", file = "i.mp3"},
{ start = 500, out = 1000, dur = 0, name = "am", file = "am.mp3"},
-- { start = 1000, out = 1000, dur = 0, name = "a", file = nil},
{ start = 1000, out = 1500, dur = 0, name = "a cat.", file = "cat.mp3", action = "onComplete"},
}
props.language.jp ={
{start = 0, out = 500, dur = 0, name = "ぼく", file = "i"},
{start = 500, out = 1000, dur = 0, name = "ねこ", file = "cat", action = "onComplete"},
}
props.wordTouch = true
props.sentenceDir = "i_am_a_cat" -- wordTouch
props.layer = "iamacat"
C: my name is kwik
local props = {
name = "my_name_is_kwik",
filename = "my_name_is_kwik.mp3",
type = "sync",
language = {},
folder = "page3",
}
--
-- action is added by sync props
--
props.language.en = {
{ start = 0, out = 500, dur = 0, name = "My", file = "" },
{ start = 500, out = 1000, dur = 0, name = "name", file = ""},
{ start = 1000, out = 1000, dur = 0, name = "is", file = ""},
{ start = 1000, out = 1500, dur = 0, name = "Kwik.", file = "", action = "onComplete"},
}
props.language.jp = {
{start = 0, out = 500, dur = 0, name = "なまえ", file = ""},
{start = 500, out = 500, dur = 0, name = "は", file = ""},
{start = 500, out = 1000, dur = 0, name = "くいっく", file = "", action = "onComplete"},
}
props.wordTouch = false
props.sentenceDir = nil -- wordTouch
props.readDir = "leftToRight"
props.layer = "mynameiskwik"
D: my father is nice
local props = {
name = "myfatherisnice",
filename = "my_father_is_nice.mp3",
type = "sync",
language = {},
folder = nil,
}
--
-- action is added by sync props
--
props.language.en = {
}
props.language.jp = {
}
props.wordTouch = false
props.sentenceDir = nil -- wordTouch
props.readDir = "leftToRight"
props.layer = "myfatherisnice"