Dobra, by być słownym, mały opis, jak to działa...
Bazą do silnika jest taka biblioteczka do Rubiego o nazwie Flow.
Projekt jest porzucony i nieco funkcjonalności mu brakuje, ale jako podstawa jest całkiem fajny.
Tworzy on szereg klas o wspólnym kodzie dla Androida i iOS, w tym: obsługa JSON, requestów http, UI itp.
Kod:
https://github.com/HipByte/Flow.gitPrzy czym, biblioteka jest porzucona i pewnych rzeczy jej brakuje.
Wprowadzone na potrzeby Eltena modyfikację:
Moduł UI::Text nie jest polem statycznym, jak tutaj, tylko polem edycyjnym, tekst statyczny to zaś jego submoduł StaticText.
Dopisane funkcje i atrybuty:
UI::Text oraz UI::TextInput posiadają zdarzenia :blur na wyjście kursora, :show na wejście w pole, :change na wpisanie, usunięcie and so on.
UI::TextInput posiada flagę UI::TextInput::Numeral służącą do wymuszenia wprowadzania liczb.
UI::View posiada funkcję scale skalującą okno, aby np. zmniejszyć go do połowy wysokości ekranu: view.scale(1,0.5)
Moduł UI::List posiada funkcję scroll(index), która przenosi kursor na wybraną pozycję listy.
Moduł UI::Label posiada flagę UI::Label::Header, zgadnijcie, poco.
Na pewno o czymś zapomniałem, bo kodu pod ręką nie mam, ale to tak mniej-więcej.
Plus przepisałem wszystkie moduły tak, by poprawić ich zgodność z Voice Overem.
Pierwszym celem dla Androida byłoby więc zaimplementowanie tych modyfikacji.
Następny krok to napisanie odtwarzacza, tutaj wzorem Elten Desktop, a więc wypełnić trzeba funkcjami i podobnymi rzeczami moduł:
module Sound
class Player
def initialize(filename)
# initializes player of a file or stream URL
end
def play
# plays a file
end
def stop
# stops a file
end
def pause
# pauses a file
end
def resume
# resumes file playing
end
def duration
# file duration in seconds, float
end
def position
# current position in seconds, foat
end
def position=(pos)
# slides to position pos in seconds, float
end
def format
# returns file format
end
def bitrate
# returns fil bitrate
end
def freq
# return file freq
end
def freq=(val)
# changes frequency to freq
end
def source
# returns stream source
end
def source=(src)
# changes file source and resets positon
end
def volume
# returns volume as float value from 0 to 1
end
def volume=(val)
# changes volume to val
end
def mode
# returns mode, 0 speaker, 1 phone speaker
end
def mode=(val)
# changes mode to val
end
def state
# returns 0 if not playing, 1 if playing, 2 if paused, 3 if error
end
def error
# returns 0 if no error occurred, error code otherwise
end
end
class Recorder
def self.permitted?
# returns true if so, false in other case
end
def self.request_permission
# requests recording permission, returns true if success
end
def initialize(filename)
# initializes recording
end
def error
# if any error occurred, returns its code, otherwise 0
end
def start
# starts recording
end
def stop
# stops recording and saves file
end
def pause
# pauses recording
end
def resume
# resumes recording
end
def duration
# recording duration in seconds, float value
end
def state
# returns 0 if ready, 1 if recording, 2 if paused, 3 if error
end
attr_accessor :format # file format, defaults to wav
attr_accessor :freq #recording frequency, defaults to 44100
attr_accessor :bitdepth # bit depth, defaults to 16
attr_accessor :bitrate # used if compression format selected, defaults to 96000
end
end