Playing a video.... test...wip

Monkey Forums/Monkey Programming/Playing a video.... test...wip

Paul - Taiphoz(Posted 2013) [#1]
OK, first of all, FLASH can just go jump off a cliff, for some god only knows reason it refuses to even BUILD, I have a post in the flash forum about this if anyone cares to take a peek.

OK, on topic, Today I set about getting my video intro into my monkey games, my video intro can be seen here


It's nice and short, only 3 seconds long.

Here it is running in html5, it works on all targets bar flash(and possibly ios i cant test it as I dont have a mac)

https://dl.dropboxusercontent.com/u/56777267/code/Alpha/StickRun/html5/MonkeyGame.html
and an Android apk
https://dl.dropboxusercontent.com/u/56777267/code/Alpha/StickRun/MonkeyGame-debug.apk

What I would love is a little feedback, does it run smooth enough, is it laggy and out of sync, is the animation speed ok.. just general aesthetics of it all.

thanks.


Skn3(Posted 2013) [#2]
Runs nicely although slightly long load time in html.

Logo looks clean as well. Have you written a video module for monkey then?


ImmutableOctet(SKNG)(Posted 2013) [#3]
Well, the HTML5 demo runs at full speed (60FPS) for me. I'll need to throw the APK on my tablet later to test the android build. As a side note; I'm not sure if there was supposed to be audio or not. It was silent for me, so I can only assume there's no audio yet (Which is perfectly fine with me).

So, how did you end up doing this? Is it all platform specific / native, or was it purely written in Monkey?


Paul - Taiphoz(Posted 2013) [#4]
@Sonic : there is audio, what browser you using ?

@Skn3, I'm trying to make the class as modular as possible so I can simply call it and play without any more than two lines of code, so in a sense yeah I guess.

But it's not calling any native code, I had a look at Androids VideoPlay, and I could probably do android native but I wanted something that's quick hassle free and that I could deploy on anything without having to worry about codec's, so I went the decompression route.

I might see if I can pack the files and audio into a single file possibly come up with a little monkeyvideo file format, but not sure if that's worth while.


rIKmAN(Posted 2013) [#5]
Looks good mate!

What software did you use to make the animated part, After Effects or similar or is it done by hand?


ImmutableOctet(SKNG)(Posted 2013) [#6]
I was using an older build of Opera, so that may be why. I tried it in Chrome and it worked with the audio. However, Chrome took about 4x as long to load everything.


skape(Posted 2013) [#7]
Looks nice and smooth in Firefox on my Mac.
60 fps, ~4 sec load time,
No sound though.

Plays smoothly in Safari.
60 fps, ~5 sec load time,
Sound works, but seems badly out-of-sync.


Raph(Posted 2013) [#8]
I had sound on Firefox in Win7. The load time was definitely disconcerting though.


Tibit(Posted 2013) [#9]
Cool, I like it.

Do you stream it directly from youtube?


Paul - Taiphoz(Posted 2013) [#10]
Yeah it's loading 2 meg, the original youtube video is 3 or 4 meg tho so I'v managed to reduce the total size by a fair amount without any compression, so its not to bad.

I expected the html5 results to be mixed, as is always the case with html5 at the moment there seems to not be a standard from the browsers, hence why I am so annoyed that Flash simply refuses to build the project.


Paul - Taiphoz(Posted 2013) [#11]
Here is a Flash Example if you could take a look guys..

https://dl.dropboxusercontent.com/u/56777267/code/Alpha/StickRun/flash/MonkeyGame.html

Seemes Diddy was having issues with flash , commenting out the offending line seems to have fixed the issue, will need to poke Samah and therevills and see if its something they can fix.


rIKmAN(Posted 2013) [#12]
As nice as it looks, 2mb for a 3sec animated logo is a bit much for me, especially if it's streamed from YouTube and I'm on a crap connection / mobile.


Paul - Taiphoz(Posted 2013) [#13]
those load times will only really be an issue for html5 and flash, and both of those issues can be resolved by at the least presenting the user with a little nice loading bar.

I do agree tho having native support via real codecs would be best but so far this seems like a really easy and working solution.


Goodlookinguy(Posted 2013) [#14]
How exactly is the system handling the videos. I assume it's just loading a bunch of separate image files and the audio.

I made something like that a while back and was looking into creating an image-only file compactor, but it didn't turn out very well. PNG and JPEG was a tad hard for me to uncompress and since bitmap was simple, I used that. However, it just ended up taking way longer to load since Monkey dumps the whole file into memory all at once. It's not very viable to say the least.

Anyways, nice job. Good luck on your endeavors.


rIKmAN(Posted 2013) [#15]
Each to their own but a loading bar that had me waiting to show a 3sec splash screen that is nothing to do with the game I am trying to play would really do my head in.


Paul - Taiphoz(Posted 2013) [#16]
Well first of all as I said before, this very short delay is only imposed for a very few targets, ala Html5, Flash, and there are things that can still be done to reduce the delay further which is nice.

All the other targets just get it done no questions, no delay which is brilliant :)

As for the loading bar on those few targets where loading times and internet bandwidth might be an issue, the end user is never going to notice it, they see loading bars all over the net for just about every game they play, its not an alien thing they will gasp in horror at, as far as any end user is concerned the game is loading game play assets.

At the end of the day no one is forcing you to use it, it's possible and there if you want to use it.

is that not the important thing here?


Shinkiro1(Posted 2013) [#17]
Can we use mojo draw commands to draw over the video? That would be cool :)

PS: Tested html and it ran smoothly, although the sound was delayed.
Tested on a MacBook Air + Safari


rIKmAN(Posted 2013) [#18]
I wasn't having a pop mate, no need to get defensive :)

My point was that if I play your game on my phone, and you are streaming a 2mb file just to show me your logo then I am gonna get annoyed at waiting for it to stream from YouTube, when I then still have to wait for the actual game assets to load.

If the file is local then great, no delay, but I don't see how there could be no delay via YT streaming, that is dependant on connection surely?

I'm looking purely from an end-user POV btw.


Paul - Taiphoz(Posted 2013) [#19]
Yeah you can draw over the top of the video because its decompressed into frames.


skape(Posted 2013) [#20]
The Flash version works great. The load was quite fast for me, maybe 1-2 seconds--not at all a worry. Of course, I wasn't loading it over a bad connection, so I could see the wait being concerning I guess. The loading... screen makes it fine IMO though.


therevills(Posted 2013) [#21]
The HTML5 version might run faster if you compile in Release mode ;)

Looks good BTW :)

So I guess you are loading in a heap of images and running thru the animation like a flip book... not really that memory friendly.

Could you do the animation using tweening? Diddy has the Storyboard system - although someone (*cough*Samah*cough*) didnt finish the editor so its a lot of hands on XML editing...


Paul - Taiphoz(Posted 2013) [#22]
Yeah thats it , and playing the audio at the appropriate time to sync it, its not ideal but the image array is wiped after its done so the memory is not being wasted it should be free for the game to use.

not ideal at all, but in the absence of a better solution, it works.


therevills(Posted 2013) [#23]
Just to put the video memory into perspective, your images are 640x360 in size (texture memory calc is width * height * bitdepth (4 bytes for 32bit)):
640 * 360 * 4 = 921600 = 900 KB = 0.88 MB

And it looks like you have 90 images:
0.88MB * 90 = 79.2MB

So nearly 80MB of VRAM just for the splash screen... just something to think about ;)


not ideal at all, but in the absence of a better solution, it works.

A better solution would to use tweening or something similar so you code the animation.


Raul(Posted 2013) [#24]
@therevils:

or someone good enough code some function to play a movie from internal memory.


rIKmAN(Posted 2013) [#25]
@Taiphoz
I would have to check it's OK with them (can't see why not) but I can sell you my licence to full version Spriter for £10 (£16/$25 on the site) as I have recently moved to Spine and have no real need for it anymore.

This is tween-based animation, which is what therevills mentioned re: video mem hogging.

No probs if not, but the offer is there mate! :)


Paul - Taiphoz(Posted 2013) [#26]
Stiff like my intro probably cant be done the same way with tweening, there is actually a load of things happening in there lots of little layers moving around and procudral effects to handle the glowing lines, I doubt I could get even close to the same effect with tweening.

THAT BEING SAID....

I have the Spriter demo and I did actually make another intro with it, so yeah it's deff a good idea and some one should deff look at it in terms of handling the animation data for a short intro.

@rIK, thanks for the offer mate but i wont need it at the moment.

@therevills my maths got it a little larger than your's but either way, as I said it's not like I will be keeping those images in memory after they are played, so they get freed from memory right after the animation is done, so that memory hit is very short lived, I guess its only limitation would be the device and how much it has available.

Its deff not a system you would want to use for anything thats longer than a few seconds.

I would love to spend the time and write a proper module to use the native api's codec's and native video playing functionality but it's beyond me sadly.


therevills(Posted 2013) [#27]
To my knowledge there isn't a demo version of Spriter, just the "free" and "pro" version... and to me the free version is enough :)

my maths got it a little larger than your's

Did I make a mistake?

as I said it's not like I will be keeping those images in memory after they are played,

Yep that's fine as long as you aren't targeting low-end devices (e.g. crappy Android devices) which might not have much VRAM spare to begin with.

And please don't get me wrong I like what you have done, I just wanted to highlight the limitations :)


Paul - Taiphoz(Posted 2013) [#28]
I do not have the hardware to test for low end specs from low end mobiles so I wont be really caring about them, unless I get a low end device that might change but in situations like that I will simply tune the video to fit.

Math, nah mate your math is fine I was just counting a few extra assets which your not aware of.

Highlighting limitations is always a good thing helps up see where we can make improvements.