Think I figured out some issues I had. First of all, iOS doesn't report back anything useful on video-position and duration, so that was a lost cause. Instead I just hacked together a solution that do actually work, and amazingly without flicker at the loop point as such a solution would entail on Android. Peek at code below to see the hack:
function gameLoop(gs ref as gameState_t, cp as cardProp_t, wr as words_t[], mt ref as txtProp_t)
ct as card_t[2]
cardSel as integer
videoDuration as float
clearSprites(sprite.cRight, sprite.cRight)
gs.cardTarget = randomCards(ct, wr.length)
importIcons(ct, wr)
placeStars(gs.cardTries)
//placeTarget(wr, gs)
downloadVideo("proto", wr[gs.cardTarget].video, mt)
if ios
dot as string
dot = "."
repeat
print(dot)
dot = dot + "."
sync()
sleep(2000)
until getFileExists("target.mp4")
endif
videoDuration = playTargetVideo()
fadeVideo("in")
placeCards(cp)
fadeInCards()
endLoop = false
gs.cardCount = 0
repeat
// get if winner card is selected
if getSelectCard(ct, gs)
gs.score = gs.score + (4 - gs.cardCount)
displayCorrect(gs.cardRight, cp)
endLoop = true
endif
// get new deck if count limit
if gs.cardCount => gs.cardTries
endLoop = true
endif
// loop at video-end
if endLoop = false
if ios
if GetVideoPlaying() = false
PlayVideoToImage(media.video)
endif
elseif GetVideoPosition() > videoDuration - 0.5
SetVideoPosition(0.00)
endif
endif
sync()
until endLoop
// replay with audio
if ios
if GetVideoPlaying()
StopVideo()
endif
PlayVideoToImage(media.video)
else
SetVideoPosition(0.00)
endif
SetVideoVolume(100)
repeat
sync()
until GetVideoPlaying() = false
fadeVideo("out")
stopTargetVideo()
clearSprites(sprite.card[0], sprite.card[sprite.card.length])
endFunction
function downloadVideo(cat as string, video as string, mt ref as txtProp_t)
fQuery as string
fQuery = "/video/" + cat + "/"
loading as string
loading = "Loading"
http = CreateHTTPConnection()
SetHTTPHost(http, ip.videos, 0)
SetHTTPTimeout(http, 5000)
if ios
if GetFileExists("target.mp4")
DeleteFile("target.mp4")
endif
sync()
sleep(250)
endif
// downloading new ones
GetHTTPFile(http, fQuery + video, "target.mp4")
if ios = false
setWaitStatus(true, mt)
endif
repeat
if ios = false
SetTextString(txt.fileLoad, str(GetHTTPFileProgress(http), 2) + "%")
else
loading = loading + "."
print(loading)
endif
sync()
until GetHTTPFileComplete(http) = true
if ios = false
setWaitStatus(false, mt)
endif
CloseHTTPConnection(http)
DeleteHTTPConnection(http)
sync()
endFunction
The ios variable I'm checking against is just a global flag right at the start of the main file. So set to true (1) if compiling for iOS, false (0) if for Android. Awful quick little hack, but as I said, it do work.
Another issue, two of my videofiles got Nordic characters in them - no not Thor, Loke, Frey or Wotan - but the more mundane æ, ø and å. Which is fine on Win10, Linux, OSX and Android - but apparantly not on iOS. So every time the app tried to send a request for those video files to the server with those characters in their name, it threw a hissy fit, promtly refused to cooperated and quit to desktop. Is it desktop on phone/tablet? Home Screen? Anyhow, had to fix that as well, but that was easy enough - quick edit of a json on the server, rename the two offending files and done.
Finally there are some caching and async timing issues with iOS when transferring over http that I have yet to figure out entirely. The app gets ahead of itself now and again, causing trouble. So far solved with a brutish delete of the temp file it saves the downloaded video to, and a sleep() command at a strategic place, but it is very ugly. I need see if I can't get it more to my liking over the weekend. In between beer, War Thunder and maybe some Kerbal Space Program. Hmmmm, Methinks Jeb is up for a trip to Minmus