Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

[Scripting]Graphics.isVideoPlaying Query

Status
Not open for further replies.
I've been playing around with movies/videos in RMMV and started poking around in Graphics.

Now you'd think that logically this (as an example) would work:

Code:
Graphics.playVideo('movie');
if (Graphics.isVideoPlaying) {
  <Do something>
} else {
  <Do something else>
}
However, while it does return true when the video's playing, it still seems to return false or null after reaching EOF. Similarly, its other functions, onVideoEnd and isVideoVisible don't produce expected results either.

Any thoughts on this?
 

eivl

Local Hero
Xy$
0.00
Should it not return false when the video has ended?
JavaScript:
Graphics.isVideoPlaying = function() {
    return this._video && this._isVideoVisible();
};
_video is null when it is initialized, and _isVideoVisable() returns false or true.
 
_video is null when it is initialized
Makes sense. Because obviously there's no video at initialization until it's started loading. And that part is fine after starting: isVideoPlaying returns true.

_isVideoVisable() returns false or true.
You'd think so, but it doesn't seem to. At least not in the "expected" way. You'd expect that _onVideoEnd would return true if the video EOF has actually been reached (i.e. the video has ended and is not visible) . Instead, it returns visibility (both video and canvas opacity), and doesn't appear to output anything but false, and opacity is zero, regardless.

So "if the video is playing, wait for it to end then continue, otherwise do something else" doesn't quite work. E.g. with background music, you'd expect that statement to be true and the music plays after the video's ended; it still plays some way through the video.
 

eivl

Local Hero
Xy$
0.00
I read something about video and transparancy, would have to check it when i get home, i am on the road now.
[doublepost=1446533532,1446491358][/doublepost]How can i reproduce this myself?
 
Um...I can't recall the exact format I used - deleted the .js file, as it was just experimenting - but it was basically on the lines of this (from memory):

JavaScript:
var _Scene_Title_playTitleMusic = Scene_Title.prototype.playTitleMusic;
    Scene_Title.prototype.playTitleMusic = function() {
        Graphics.playVideo('movies/PretitleMovie.webm');
        if (Graphics.isVideoPlaying) {console.log('Video is playing');}
        if (Graphics._onVideoEnd) { console.log(Graphics._onVideoEnd, Graphics._updateVisibility, 'End', Graphics._video.style.opacity); }
        _Scene_Title_playTitleMusic;
    }
(The playVideo function was actually somewhere at the start of Scene_Title. The idea is play the video, check if it's playing and when it reaches the end of the video play the BGM).

There was more to it than that, I think, and it was better coded, but I did it like that to output each of the steps and to see how all of the processes in the grand scheme of JGSS works.

isVideoPlaying
returns true. onVideoEnd doesn't (which you'd probably expect means when the video ends), almost immediately displaying "End [of video]" and its transparency equalling 0. And the BGM doesn't play, since (my understanding) it doesn't reach EOF, but instead uses opacity on/off.

I'm sure I'm overlooking something; not new to Javascript, but still really trying to find how it's all put together in RMMV.
 

eivl

Local Hero
Xy$
0.00
you are not calling the original playTitleMusic.
you need to call it after the video

JavaScript:
_Scene_Title_playTitleMusic.call(this);
 
Of course! I think I did put that, but as I said most of that was from memory. onVideoEnd will still output 0 opacity (immediately after "Video is playing") and the BGM will still play partway through the video. No pause. That's kinda why I don't think it's actually registering as EOF or that opacity is changing.

Perhaps a "wait" function before the aliased playTItleMusic for the movie's duration? (How'd I do that anyway?!) Remembered how to do this!

In RMVXA, there isn't a lot you can do with the Graphics.play_movie. Have to wait until the movie's finished before anything will execute. RMMV seems to have the opposite.
 
Last edited:

eivl

Local Hero
Xy$
0.00
There is a bind function to the hasvideoended thing somewhere... Check what it does, honestly i dont remember that.
 
There is a bind function to the hasvideoended thing somewhere... Check what it does, honestly i dont remember that.
I seem to recall that too. Now where is it?! But I've been digging into the depths of Graphics, doing that well-oiled action of tracing what everything does, when, where and where it leads, right?Px I may be onto something...Mabye!
 

eivl

Local Hero
Xy$
0.00
Do you not use a javascript debugger?

Setting out breakpoints are so usefull :)

I can find it when i get on my workstation :)
 
Chrome, Firefox and occasionally Avant. I know that Firefox is meant to have a really good console thingy...

But.... GOT IT! Here:


It's far from perfect, but it works. Movie plays before Title Screen, then BGM plays on the Title Screen. (The BGM delay isn't related to the plugin; it happens even with it turned off. Just the way it's preloaded/rendered, I think.)

You can hear me snuffling; I have a cold!
 
Last edited:
Status
Not open for further replies.
Top