设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 4121|回复: 14
打印 上一主题 下一主题

[有事请教] 视频标题插件PH_VideoTitle

[复制链接]

Lv2.观梦者

梦石
0
星屑
451
在线时间
64 小时
注册时间
2019-8-9
帖子
9
1
发表于 2019-11-12 22:06:37 手机端发表。 | 显示全部楼层
更明显了,PixiJs版本老了,回去改一下,

点评

改了是黑屏,然后屏蔽了下面两个 是显视频第一帧图片,不播放视频啊  发表于 2019-11-13 01:44
新版已经不用PIXI.VideoTexture.textureFromVideo这样的写法了,改用PIXI.Texture.from或PIXI.Texture.fromVideo这样的写法了,而PIXI.Texture.fromVideo也在pixijsV5中将被弃用  发表于 2019-11-12 23:42
神了 您怎么看出来的?  发表于 2019-11-12 23:37
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
451
在线时间
64 小时
注册时间
2019-8-9
帖子
9
2
发表于 2019-11-13 09:54:55 | 显示全部楼层
/*:

PH - Video Title
@plugindesc This plugin allows you to put a video at the background of the Title Screen instead of a static image.
@author PrimeHover
@version 1.1
@date 11/12/2015

---------------------------------------------------------------------------------------
This work is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/
---------------------------------------------------------------------------------------

@param Video Name
@desc Name of the video (See Help Section) | (E.g. "myVideo")

@param Video Muted
@desc Mutes the video in the title (0: No, 1: Yes)
@default 0

@param Video Loop
@desc Makes the video plays in a loop (0: No, 1: Yes)
@default 1

@param Video Poster Name
@desc Name and extension of the image to be shown when the video is loading (E.g. "poster.png")

@param Video Width
@desc Width of the video in the canvas (Default: 816)
@default 816

@param Video Height
@desc Height of the video in the canvas (Default: 624)
@default 624

@param Video Coord X
@desc Coordinate X of the video in the canvas (Default: 0)
@default 0

@param Video Coord Y
@desc Coordinate Y of the video in the canvas (Default: 0)
@default 0

@help

The video you want to play in background must be inside the "movies" folder in your project.
Supported extensions: "webm"

The poster you want to show while the video is not ready must be inside the "pictures" folder in your project.


Maintenance by Mikan on 2019.11.13
For PixiJs v4

*/

(function() {

    /* Getting the parameters */
    var parameters = PluginManager.parameters('PH_VideoTitle');
    var videoName = String(parameters['Video Name']);
    var posterName = String(parameters['Video Poster Name']);
    var videoMuted = Number(parameters['Video Muted']);
    var videoLoop = Number(parameters['Video Loop']);
    var videoWidth = Number(parameters['Video Width']);
    var videoHeight = Number(parameters['Video Height']);
    var videoX = Number(parameters['Video Coord X']);
    var videoY = Number(parameters['Video Coord Y']);

    /* Video Title Class */
    var PH_VideoTitle = null;

    function VideoTitle() {
        this.name = videoName;
        this.posterName = posterName;

        this.setVideoTexture();
    }
    VideoTitle.prototype.constructor = VideoTitle;

    VideoTitle.prototype.setControlOptions = function() {
        if (videoLoop == 1) {
            this._video.loop = true;
        } else {
            this._video.loop = false;
        }

        if (videoMuted == 1) {
            this._video.muted = true;
        } else {
            this._video.muted = false;
        }

        if (posterName.trim() != '') {
            this._video.poster = 'img/pictures/' + this.posterName;
        }
    };

    VideoTitle.prototype.getVideoSrc = function() {
        return 'movies/' + this.name + '.webm';
    }

    VideoTitle.prototype.setVideoTexture = function() {
        this._texture = PIXI.Texture.from(this.getVideoSrc());

        this._video = this._texture.baseTexture.source;
        this.setControlOptions();

        this._texture.baseTexture.source.pause();

        this._spriteVideo = new PIXI.Sprite(this._texture);
        this._spriteVideo.width = videoWidth;
        this._spriteVideo.height = videoHeight;
        this._spriteVideo.x = videoX;
        this._spriteVideo.y = videoY;
    };

    VideoTitle.prototype.pauseVideo = function() {
        this._video.pause();
    };

    VideoTitle.prototype.playVideo = function() {
        this._video.play();
    };

    VideoTitle.prototype.update = function() {
        this._texture.update();
    };


    /* Overwritten Scene_Title methods */
    Scene_Title.prototype.create = function() {

        /* Prevent the video to be duplicated */
        if (PH_VideoTitle === null) {
            PH_VideoTitle = new VideoTitle();
        }
        this.videoTitle = PH_VideoTitle;
        this.addChild(this.videoTitle._spriteVideo);
        this.createForeground();
        this.createWindowLayer();
        this.createCommandWindow();
    };

    Scene_Title.prototype.start = function() {
        Scene_Base.prototype.start.call(this);
        SceneManager.clearStack();
        if (videoMuted == 1) {
            this.playTitleMusic();
        }
        this.startFadeIn(this.fadeSpeed(), false);
    };

    Scene_Title.prototype.terminate = function() {
        Scene_Base.prototype.terminate.call(this);
        this.videoTitle.pauseVideo();
        SceneManager.snapForBackground();
    };

    var _MK_Scene_Title_update = Scene_Title.prototype.update;
    Scene_Title.prototype.update   = function() {
       _MK_Scene_Title_update.call(this);
       this.videoTitle.update();
    };

})();

点评

大佬你这个能播放视频,但是打开设置或者进入游戏再返回标题界面就又变成静态图片了  发表于 2019-11-15 00:38
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
451
在线时间
64 小时
注册时间
2019-8-9
帖子
9
3
发表于 2019-11-13 09:57:12 | 显示全部楼层

适应了RMMV的pixiJS v4版本

点评

感谢大佬指点,仔细对比了和你的代码的区别,除了你的闭包,我的没闭包,发现没什么其它不同,我闭包之后,应该就没问题了。  发表于 2019-11-15 13:15
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-21 01:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表