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

Project1

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

[有事请教] MoviePicture.js 視頻怎麼樣都是黑黑一片.請問各位大大如何解...

[复制链接]

Lv4.逐梦者

梦石
0
星屑
7013
在线时间
1358 小时
注册时间
2018-12-16
帖子
1939
跳转到指定楼层
1
发表于 2020-9-19 19:07:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 play337 于 2020-9-20 10:56 编辑

1.7.0 就 OK 了...

https://rpg.blue/forum.php?mod=v ... p;page=1#pid2903149

----------------------------------------
MoviePicture.js 視頻怎麼樣都是黑黑一片.請問各位大大如何解決呢?

01.插件是最新版本的了...
02.視頻格式應該沒有問題...因為只要關掉這個插件就一切正常...

1.7.1 一片黑黑(有聲音沒有影像)
1.5.0 一片黑黑(有聲音沒有影像)
1.4.0 一片黑黑(有聲音沒有影像)

---------------------------------

ふりがな:どうがのぴくちゃひょうじ

機能概要: ピクチャの表示枠を使って動画を再生します。

利用規約(ライセンス): MITライセンス

作者:トリアコンタン

作者サイト:https://twitter.com/triacontane/

ダウンロードページ:https://raw.githubusercontent.com/triacontane/RPGMakerM

解説ページ:https://triacontane.blogspot.jp/2017/08/blog-post.html

ファイル名:MoviePicture.js
---------------------------------

//=============================================================================
// MoviePicture.js
// ----------------------------------------------------------------------------
// (C)2017 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.7.1 2019/08/26 他のプラグインとの組み合わせによりエラーになる可能性のある記述を修正
// 1.7.0 2019/06/30 動画の取得元フォルダと拡張子を変更して動画を難読化できるようにしました。
// 1.6.0 2019/06/29 複数の動画を並行してロードしているときは、すべての動画のロードが完了してから再生するよう変更しました
//                  一定フレームで動画を中断させるコマンドを追加
// 1.5.1 2019/06/29 画面遷移したとき、動画でないピクチャまで非表示になってしまう問題を修正
// 1.5.0 2019/06/11 動画再生終了後、動画ピクチャを自動削除せず最終フレームで静止したままにする機能を追加
// 1.4.1 2019/05/21 動画を縮小表示したときのジャギを軽減
//                  ヘルプの記載を本体バージョン1.6を前提に修正
// 1.4.0 2019/01/06 movieフォルダ以外の場所に配置されている動画ファイルを再生できる機能を追加
// 1.3.3 2018/11/08 再生開始直後に停止したとき、特定条件下で正常に停止しない問題を修正
// 1.3.2 2018/06/17 ピクチャの消去によって動画再生を終了した場合に、再生速度と音量が初期化されない問題を修正
// 1.3.1 2017/08/27 二連続で再生したときに動画の音量同期機能が正常に動作しない問題を修正
// 1.3.0 2017/08/26 動画の音量をいずれかのオーディオ音量と同期させる機能を追加
// 1.2.0 2017/08/18 動画の再生速度(倍率)を変更できるプラグインコマンドを追加
// 1.1.0 2017/08/09 アルファチャンネル付き動画の再生に対応(ただし特定の手順を踏む必要あり)
// 1.0.3 2017/08/08 エラー処理を追加
// 1.0.2 2017/08/07 環境に関する制約を追加
// 1.0.1 2017/08/07 リファクタリング(仕様の変更はなし)
// 1.0.0 2017/08/06 初版
// ----------------------------------------------------------------------------
// [Blog]   : https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================

/*:
* @plugindesc MovieInScreenPlugin
* @author triacontane
*
* @param MovieVolumeType
* @desc 動画再生時に音声が含まれる場合、その音量を参照するオーディオ種別です。指定しない場合、常に100%で再生されます。
* @default none
* @type select
* @option none
* @option BGM
* @option BGS
* @option ME
* @option SE
*
* @param AutoEraseOnEnd
* @desc 動画再生終了時に動画ピクチャを自動で削除します。
* @default true
* @type boolean
*
* @param MovieFolder
* @desc 動画ファイルの取得元フォルダです。指定しない場合は「movies」フォルダが使用されます。
* @default
*
* @param WebmExt
* @desc webm形式を再生するときの偽装拡張子です。難読化したい場合に指定します。対応フォーマットが増えるわけではありません。
* @default
*
* @param Mp4Ext
* @desc mp4形式を再生するときの偽装拡張子です。難読化したい場合に指定します。対応フォーマットが増えるわけではありません。
* @default
*
* @help Play movies using the picture display frame.
* In addition to being subject to processing by moving and rotating pictures,
* parallel playback of multiple videos
* It will be possible. Also, the movie will be displayed at the bottom of
* the window. However, it does not correspond to "color tone change of picture".
*
* This plugin can only be used with core script ver1.5.0 or later.
*
* Currently there is a problem that the video may not be played properly
* with PC Firefox. For the time being we will only support local execution.
*
* After preparing movie files with plug-in command "MP_SET_MOVIE"
* Please execute the event designation "Show Picture"
* with the file designation empty.
*
* Plugin Command
*
* MP_SET_MOVIE file  # 動画ファイル[file]を準備します。
* MP_SET_LOOP 1 on   # ピクチャ番号[1]の動画がループ再生されます。
* MP_SET_PAUSE 1 on  # ピクチャ番号[1]の動画が一時停止します。
* MP_SET_WAIT 1      # ピクチャ番号[1]の動画が再生するまでイベントを待機します。
* MP_SET_VOLUME 1 50 # ピクチャ番号[1]の動画の音量を50%に設定します。
* MP_SET_SPEED 1 150 # ピクチャ番号[1]の動画の再生速度を150%に設定します。
*
* Prepare a video file that exists in a path other than the movie folder.
* The [path] you specify is relative to the path where the save folder exists.
* Extension is required.
* MP_SET_OUTER_MOVIE path # 動画ファイル[path]を準備します。拡張子必須
* MP_外部動画設定 path    # 同上
*
* Set the movie sound volume type.
* MP_SET_VOLUME_TYPE BGM
*
* Caution:
* If you play multiple large movies, the performance may be degraded.
*
* This plugin is released under the MIT License.
*/
/*:ja
* @plugindesc 動画のピクチャ表示プラグイン
* @author トリアコンタン
*
* @param 動画音量種別
* @desc 動画再生時に音声が含まれる場合、その音量を参照するオーディオ種別です。指定しない場合、常に100%で再生されます。
* @default none
* @type select
* @option none
* @option BGM
* @option BGS
* @option ME
* @option SE
*
* @param 終了時自動削除
* @desc 動画再生終了時に動画ピクチャを自動で削除します。削除しない場合、動画は最終フレームで静止します。
* @default true
* @type boolean
*
* @param 動画取得フォルダ
* @desc 動画ファイルの取得元フォルダです。指定しない場合は「movies」フォルダが使用されます。末尾のスラッシュは不要です。
* @default
*
* @param webm偽装拡張子
* @desc webm形式を再生するときの偽装拡張子です。難読化したい場合に指定します。対応フォーマットが増えるわけではありません。
* @default
*
* @param mp4偽装拡張子
* @desc mp4形式を再生するときの偽装拡張子です。難読化したい場合に指定します。対応フォーマットが増えるわけではありません。
* @default
*
* @help ピクチャの表示枠を使って動画を再生します。
* ピクチャの移動や回転による処理の対象になるほか、複数の動画の並行再生が
* 可能になります。また、動画がウィンドウの下に表示されるようになります。
* ただし「ピクチャの色調変更」には対応していません。
*
* このプラグインは本体ver1.6.0以降でのみ使用できます。
*
* 現在、スマートデバイスで実行したときに動画が最初のフレームで停止する
* 現象を確認しています。
* よって当面の間はローカル実行(Game.exe)のみをサポート対象とします。
*
* プラグインコマンド「MP_SET_MOVIE」で動画ファイルを準備してから
* イベントコマンド「ピクチャの表示」をファイル指定を空で実行してください。
*
* プラグインコマンド詳細
*  イベントコマンド「プラグインコマンド」から実行。
*  (パラメータの間は半角スペースで区切る)
*
* MP_SET_MOVIE file    # 動画ファイル[file]を準備します。拡張子不要。
* MP_動画設定 file     # 同上
* MP_SET_LOOP 1 on     # ピクチャ番号[1]の動画がループ再生されます。
* MP_ループ設定 1 on   # 同上(offでループ再生を解除します)
* MP_SET_PAUSE 1 on    # ピクチャ番号[1]の動画が一時停止します。
* MP_ポーズ設定 1 on   # 同上(offで再生を再開します)
* MP_SET_WAIT 1        # ピクチャ番号[1]の動画が再生するまでイベントを待機します。
* MP_ウェイト設定 1    # 同上
* MP_SET_LIMIT 1 50    # ピクチャ番号[1]の動画を50フレームで中断します。
* MP_リミット設定 1 50 # 同上
* MP_SET_VOLUME 1 50   # ピクチャ番号[1]の動画の音量を50%に設定します。
* MP_音量設定 1 50     # 同上
* MP_SET_SPEED 1 150   # ピクチャ番号[1]の動画の再生速度を150%に設定します。
* MP_速度設定 1 150    # 同上
*
* movieフォルダ以外のパスに存在する動画ファイルを準備します。
* 指定する[path]は、フルパスもしくはsaveフォルダの存在するパスからの相対パスです。
* 拡張子が必要です。
* MP_SET_OUTER_MOVIE path # 動画ファイル[path]を準備します。拡張子必須
* MP_外部動画設定 path    # 同上
*
* 動画音量種別を設定します。設定する内容はプラグインパラメータ「動画音量種別」と
* 同じです。プラグインパラメータの設定より優先されます。
* MP_音量種別設定 BGM
* MP_SET_VOLUME_TYPE BGM
*
* アルファチャンネル付き動画を使用する場合は、
* プラグインコマンド「MP_SET_MOVIE」実行時に二つめの引数をonにしてください。
* MP_SET_MOVIE file on
*
* ※ スマートデバイス環境(.mp4を使用)では透過を使用できません。
*    こちらはコーデック(H.264)の仕様なのでプラグイン側では対応できません。
*
* ・スクリプト詳細
* 指定した番号の動画ピクチャが再生終了している場合にtrueを返します。
* 存在しないピクチャ番号を指定するとエラーになります。
* このスクリプトはパラメータ「終了時自動削除」が無効な場合のみ使えます。
* $gameScreen.picture(2).isVideoEnd(); # ピクチャ[2]の再生が終了している場合にtrue
*
* 注意:
* サイズの大きな動画を複数再生すると、パフォーマンスが低下する可能性があります。
*
* 利用規約:
*  作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
*  についても制限はありません。
*  このプラグインはもうあなたのものです。
*/

(function() {
    'use strict';
    var pluginName    = 'MoviePicture';
    var metaTagPrefix = 'MP_';

    //=============================================================================
    // ローカル関数
    //  プラグインパラメータやプラグインコマンドパラメータの整形やチェックをします
    //=============================================================================
    var getParamString = function(paramNames) {
        if (!Array.isArray(paramNames)) paramNames = [paramNames];
        for (var i = 0; i < paramNames.length; i++) {
            var name = PluginManager.parameters(pluginName)[paramNames];
            if (name) return name;
        }
        return '';
    };

    var getParamBoolean = function(paramNames) {
        var value = getParamString(paramNames);
        return value.toUpperCase() === 'TRUE';
    };

    var convertEscapeCharacters = function(text) {
        if (isNotAString(text)) text = '';
        var windowLayer = SceneManager._scene._windowLayer;
        return windowLayer ? windowLayer.children[0].convertEscapeCharacters(text) : text;
    };

    var isNotAString = function(args) {
        return String(args) !== args;
    };

    var convertAllArguments = function(args) {
        for (var i = 0; i < args.length; i++) {
            args = convertEscapeCharacters(args);
        }
        return args;
    };

    var getArgNumber = function(arg, min, max) {
        if (arguments.length < 2) min = -Infinity;
        if (arguments.length < 3) max = Infinity;
        return (parseInt(arg) || 0).clamp(min, max);
    };

    var getArgBoolean = function(arg) {
        return arg && (arg.toUpperCase() === 'ON' || arg.toUpperCase() === 'TRUE');
    };

    var setPluginCommand = function(commandName, methodName) {
        pluginCommandMap.set(metaTagPrefix + commandName, methodName);
    };

    //=============================================================================
    // パラメータの取得と整形
    //=============================================================================
    var param             = {};
    param.movieVolumeType = getParamString(['MovieVolumeType', '動画音量種別']).toUpperCase();
    param.autoEraseOnEnd  = getParamBoolean(['AutoEraseOnEnd', '終了時自動削除']);
    param.movieFolder     = getParamString(['MovieFolder', '動画取得フォルダ']);
    param.webmExt         = getParamString(['WebmExt', 'webm偽装拡張子']);
    param.mp4Ext          = getParamString(['Mp4Ext', 'mp4偽装拡張子']);

    var pluginCommandMap = new Map();
    setPluginCommand('SET_MOVIE', 'execSetVideoPicture');
    setPluginCommand('動画設定', 'execSetVideoPicture');
    setPluginCommand('SET_LOOP', 'execSetVideoLoop');
    setPluginCommand('ループ設定', 'execSetVideoLoop');
    setPluginCommand('SET_SPEED', 'execSetVideoSpeed');
    setPluginCommand('速度設定', 'execSetVideoSpeed');
    setPluginCommand('SET_PAUSE', 'execSetVideoPause');
    setPluginCommand('ポーズ設定', 'execSetVideoPause');
    setPluginCommand('SET_WAIT', 'execSetVideoWait');
    setPluginCommand('ウェイト設定', 'execSetVideoWait');
    setPluginCommand('SET_LIMIT', 'execSetVideoLimit');
    setPluginCommand('リミット設定', 'execSetVideoLimit');
    setPluginCommand('SET_VOLUME', 'execSetVideoVolume');
    setPluginCommand('音量設定', 'execSetVideoVolume');
    setPluginCommand('SET_VOLUME_TYPE', 'execSetVideoVolumeType');
    setPluginCommand('音量種別設定', 'execSetVideoVolumeType');
    setPluginCommand('SET_OUTER_MOVIE', 'execSetOuterVideoPicture');
    setPluginCommand('外部動画設定', 'execSetOuterVideoPicture');

    //=============================================================================
    // Game_Interpreter
    //  プラグインコマンドを追加定義します。
    //=============================================================================
    var _Game_Interpreter_pluginCommand      = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.apply(this, arguments);
        var pluginCommandMethod = pluginCommandMap.get(command.toUpperCase());
        if (pluginCommandMethod) {
            this[pluginCommandMethod](convertAllArguments(args));
        }
    };

    Game_Interpreter.prototype.execSetVideoPicture = function(args) {
        $gameScreen.setVideoPictureName(args[0], getArgBoolean(args[1]), false);
    };

    Game_Interpreter.prototype.execSetOuterVideoPicture = function(args) {
        $gameScreen.setVideoPictureName(args[0], getArgBoolean(args[1]), true);
    };

    Game_Interpreter.prototype.execSetVideoLoop = function(args) {
        var picture = $gameScreen.picture(getArgNumber(args[0]), 1);
        if (picture) {
            picture.setVideoLoop(getArgBoolean(args[1]));
        }
    };

    Game_Interpreter.prototype.execSetVideoPause = function(args) {
        var picture = $gameScreen.picture(getArgNumber(args[0]), 1);
        if (picture) {
            picture.setVideoPause(getArgBoolean(args[1]));
        }
    };

    Game_Interpreter.prototype.execSetVideoVolume = function(args) {
        var picture = $gameScreen.picture(getArgNumber(args[0]), 1);
        if (picture) {
            picture.setVideoVolume(getArgNumber(args[1], 0, 100));
        }
    };

    Game_Interpreter.prototype.execSetVideoLimit = function(args) {
        var picture = $gameScreen.picture(getArgNumber(args[0]), 1);
        if (picture) {
            picture.setFrameLimit(getArgNumber(args[1], 0));
        }
    };

    Game_Interpreter.prototype.execSetVideoVolumeType = function(args) {
        var picture = $gameScreen.picture(getArgNumber(args[0]), 1);
        if (picture) {
            picture.setVideoVolumeType(args[1]);
        }
    };

    Game_Interpreter.prototype.execSetVideoWait = function(args) {
        var picture = $gameScreen.picture(getArgNumber(args[0]), 1);
        if (picture) {
            picture.setVideoWait(true);
            this._waitMode = 'videoPicture';
        }
    };

    Game_Interpreter.prototype.execSetVideoSpeed = function(args) {
        var picture = $gameScreen.picture(getArgNumber(args[0]), 1);
        if (picture) {
            picture.setVideoSpeed(getArgNumber(args[1], 10, 500));
        }
    };

    var _Game_Interpreter_updateWaitMode      = Game_Interpreter.prototype.updateWaitMode;
    Game_Interpreter.prototype.updateWaitMode = function() {
        if (this._waitMode === 'videoPicture') {
            var waiting = $gameScreen.isVideoWaiting();
            if (!waiting) {
                this._waitMode = '';
            }
            return waiting;
        } else {
            return _Game_Interpreter_updateWaitMode.apply(this, arguments);
        }
    };

    //=============================================================================
    // Utils
    //  動作環境を判定します。
    //=============================================================================
    Utils.isPcChrome = function() {
        var agent = navigator.userAgent;
        return !!(!agent.match(/Android/) && agent.match(/Chrome/)) && !this.isNwjs();
    };

    //=============================================================================
    // Game_Screen
    //  動画ピクチャを準備します。
    //=============================================================================
    Game_Screen.prototype.setVideoPictureName = function(movieName, useAlpha, useOuter) {
        this._videoUseAlpha = useAlpha;
        if (useOuter && !movieName.match(/^[A-Z]:/)) {
            const path             = require('path');
            this._videoPictureName = path.join(path.dirname(StorageManager.localFileDirectoryPath()), movieName);
        } else {
            this._videoPictureName = movieName;
        }
    };

    Game_Screen.prototype.getVideoPictureName = function() {
        return this._videoPictureName;
    };

    Game_Screen.prototype.isVideoUseAlpha = function() {
        return this._videoUseAlpha;
    };

    Game_Screen.prototype.clearVideoPictureName = function() {
        this._videoPictureName = null;
        this._videoUseAlpha    = null;
    };

    Game_Screen.prototype.isVideoWaiting = function() {
        return this._pictures.some(function(picture) {
            return picture && picture.isVideoWait();
        });
    };

    //=============================================================================
    // Game_Picture
    //  動画ピクチャに関連するプロパティを追加定義します。
    //=============================================================================
    var _Game_Picture_show      = Game_Picture.prototype.show;
    Game_Picture.prototype.show = function(name, origin, x, y, scaleX,
                                           scaleY, opacity, blendMode) {
        _Game_Picture_show.apply(this, arguments);
        var videoName = $gameScreen.getVideoPictureName();
        if (videoName && !name) {
            this._name          = videoName;
            this._video         = true;
            this._ended         = false;
            this._videoUseAlpha = $gameScreen.isVideoUseAlpha();
            this.setVideoVolume(100);
            this.setVideoVolumeType(param.movieVolumeType);
            $gameScreen.clearVideoPictureName();
        } else {
            this._video = false;
        }
    };

    Game_Picture.prototype.isVideo = function() {
        return this._video;
    };

    Game_Picture.prototype.isVideoUseAlpha = function() {
        return this._videoUseAlpha;
    };

    Game_Picture.prototype.setVideoLoop = function(value) {
        this._loopVideo = this.isVideo() && value;
    };

    Game_Picture.prototype.isVideoLoop = function() {
        return this._loopVideo;
    };

    Game_Picture.prototype.setVideoPause = function(value) {
        this._pauseVideo = this.isVideo() && value;
    };

    Game_Picture.prototype.isVideoPause = function() {
        return this._pauseVideo;
    };

    Game_Picture.prototype.setVideoWait = function(value) {
        this._waitVideo = this.isVideo() && value;
    };

    Game_Picture.prototype.isVideoWait = function() {
        return this._waitVideo;
    };

    Game_Picture.prototype.setVideoVolume = function(value) {
        this._volumeVideo = value;
    };

    Game_Picture.prototype.getVideoRealVolume = function() {
        return this._volumeVideo * AudioManager.getVideoPictureVolume(this._volumeVideoType);
    };

    Game_Picture.prototype.setVideoVolumeType = function(value) {
        this._volumeVideoType = value;
    };

    Game_Picture.prototype.setVideoSpeed = function(value) {
        this._speedVideo = value;
    };

    Game_Picture.prototype.getVideoSpeed = function() {
        return this._speedVideo || 100;
    };

    Game_Picture.prototype.setVideoPosition = function(value) {
        this._positionVideo = value;
    };

    Game_Picture.prototype.getVideoPosition = function() {
        return this._positionVideo || 0;
    };

    // used by user script
    Game_Picture.prototype.isVideoEnd = function() {
        return this._ended
    };

    Game_Picture.prototype.setVideoEnd = function() {
        this._ended = true;
    };

    Game_Picture.prototype.setFrameLimit = function(value) {
        this._frameLimit = value;
    };

    Game_Picture.prototype.getFrameLimit = function() {
        return this._frameLimit;
    };

    //=============================================================================
    // Sprite_Picture
    //  ムービーピクチャを読み込みます。
    //=============================================================================
    var _Sprite_Picture_loadBitmap      = Sprite_Picture.prototype.loadBitmap;
    Sprite_Picture.prototype.loadBitmap = function() {
        if (this.picture().isVideo()) {
            this.loadVideo();
        } else {
            _Sprite_Picture_loadBitmap.apply(this, arguments);
        }
    };

    Sprite_Picture.prototype.loadVideo = function() {
        if (SceneManager.isBattleStartUnexpectedLoad()) {
            return;
        }
        if (this.isVideoPicture()) {
            this.bitmap.destroy();
        }
        this.bitmap = ImageManager.loadVideo(this._pictureName, this.picture().isVideoUseAlpha());
        this.bitmap.addLoadListener(function() {
            this.prepareVideo();
        }.bind(this));
        this._loadingState = 'loading';
    };

    Sprite_Picture.prototype.prepareVideo = function() {
        this.refreshForVideo();
        this._playStart = true;
        var picture     = this.picture();
        if (picture) {
            this.bitmap.setCurrentTime(picture.getVideoPosition());
            this._volume = null;
            this.updateVideoVolume();
        }
        this._loadingState = 'prepared';
    };

    Sprite_Picture.prototype.refreshForVideo = function() {
        this._refresh();
    };

    var _Sprite_Picture_updateBitmap      = Sprite_Picture.prototype.updateBitmap;
    Sprite_Picture.prototype.updateBitmap = function() {
        if (!this.picture()) {
            this.clearVideo();
        }
        _Sprite_Picture_updateBitmap.apply(this, arguments);
        this.updateVideo();
    };

    var _Sprite_Picture_setBlendColor      = Sprite_Picture.prototype.setBlendColor;
    Sprite_Picture.prototype.setBlendColor = function(color) {
        if (this.isVideoPicture()) return;
        _Sprite_Picture_setBlendColor.apply(this, arguments);
    };

    Sprite_Picture.prototype.updateVideo = function() {
        if (!this.isVideoPicture()) return;
        this.bitmap.update();
        if (this.bitmap.isEnded()) {
            this.finishVideo();
            return;
        }
        if (this.picture() && this._playStart) {
            this.updateVideoSpeed();
            this.updateVideoPause();
            this.updateVideoVolume();
            this.updateVideoLoop();
            this.updateVideoWaiting();
            this.updateVideoFrameLimit();
        }
    };

    Sprite_Picture.prototype.updateVideoSpeed = function() {
        var speed = this.picture().getVideoSpeed() / 100;
        if (speed !== this._speed) {
            this._speed = speed;
            this.bitmap.setVideoSpeed(speed);
        }
    };

    Sprite_Picture.prototype.updateVideoPause = function() {
        var pause = this.picture().isVideoPause();
        if (this._pause && !pause) {
            this.bitmap.play();
        }
        if (!this._pause && pause) {
            this.bitmap.pause();
        }
        this._pause = pause;
    };

    Sprite_Picture.prototype.updateVideoLoop = function() {
        this.bitmap.setVideoLoop(this.picture().isVideoLoop());
    };

    Sprite_Picture.prototype.updateVideoVolume = function() {
        var volume = this.picture().getVideoRealVolume();
        if (volume !== this._volume) {
            this._volume = volume;
            this.bitmap.setVolume(volume / 100);
        }
    };

    Sprite_Picture.prototype.updateVideoWaiting = function() {
        var picture = this.picture();
        if (picture.isVideoWait() && !this.bitmap.isFirstLap()) {
            picture.setVideoWait(false);
        }
    };

    Sprite_Picture.prototype.updateVideoFrameLimit = function() {
        if (!this._pause) {
            this._frameCount++;
        }
        var limit = this.picture().getFrameLimit();
        if (limit > 0 && limit < this._frameCount) {
            if (this.picture().isVideoLoop()) {
                this._bitmap.setCurrentTime(0);
            } else {
                this.finishVideo();
            }
            this._frameCount = 0;
        }
    };

    Sprite_Picture.prototype.finishVideo = function() {
        this._frameCount = 0;
        if (param.autoEraseOnEnd) {
            this.eraseVideo();
        } else if (this.picture()) {
            this.picture().setVideoEnd();
        }
    };

    Sprite_Picture.prototype.eraseVideo = function() {
        this.clearVideo();
        if (this.picture()) {
            $gameScreen.erasePicture(this._pictureId);
            this.visible = false;
        }
    };

    Sprite_Picture.prototype.clearVideo = function() {
        if (!this.isVideoPicture()) return;
        var picture = this.picture();
        if (picture) {
            picture.setVideoPosition(this.bitmap.getCurrentTime());
        }
        this.bitmap.destroy();
        this._volume    = null;
        this._speed     = null;
        this._pause     = null;
        this._playStart = false;
        this.bitmap     = null;
    };

    Sprite_Picture.prototype.isVideoPicture = function() {
        return this.bitmap && this.bitmap.isVideo();
    };

    Sprite_Picture.prototype.isLoading = function() {
        return this._loadingState === 'loading';
    };

    Sprite_Picture.prototype.isPrepared = function() {
        return this._loadingState === 'prepared';
    };

    Sprite_Picture.prototype.startVideo = function() {
        this._bitmap.play();
        this._loadingState = null;
        this._frameCount   = 0;
    };

    //=============================================================================
    // Spriteset_Base
    //  再生中の動画をすべて破棄します。
    //=============================================================================
    Spriteset_Base.prototype.clearAllVideo = function() {
        this._pictureContainer.children.forEach(function(picture) {
            if (picture.clearVideo && picture.isVideoPicture()) {
                picture.clearVideo();
                picture.bitmap = null;
            }
        });
    };

    var _Spriteset_Base_update      = Spriteset_Base.prototype.update;
    Spriteset_Base.prototype.update = function() {
        _Spriteset_Base_update.apply(this, arguments);
        this.updateVideoPicture();
    };

    Spriteset_Base.prototype.updateVideoPicture = function() {
        var preparedPictures = [];
        var loading          = this._pictureContainer.children.some(function(picture) {
            if (picture.isPrepared && picture.isPrepared()) {
                preparedPictures.push(picture);
            }
            return picture.isLoading && picture.isLoading();
        });
        if (!loading) {
            preparedPictures.forEach(function(picture) {
                picture.startVideo();
            })
        }
    };

    //=============================================================================
    // Scene_Base
    //  シーン遷移時に再生中の動画をすべて破棄します。
    //=============================================================================
    var _Scene_Base_terminate      = Scene_Base.prototype.terminate;
    Scene_Base.prototype.terminate = function() {
        if (this._spriteset && this._spriteset instanceof Spriteset_Base) {
            this._spriteset.clearAllVideo();
        }
        _Scene_Base_terminate.apply(this, arguments);
    };

    //=============================================================================
    // ImageManager
    //  動画の読み込みを追加定義します。
    //=============================================================================
    ImageManager.loadVideo = function(filename, alpha) {
        if (filename) {
            return Bitmap_Video.load(this.getVideoFilePath(filename), true, this.getVideoClass(alpha));
        } else {
            return this.loadEmptyBitmap();
        }
    };

    ImageManager.getVideoFilePath = function(filename) {
        if (!filename.match(/^[A-Z]:/)) {
            return this.getVideoFileFolder() + encodeURIComponent(filename) + this.getVideoFileExt();
        } else {
            return filename;
        }
    };

    ImageManager.getVideoFileFolder = function() {
        return (param.movieFolder || 'movies') + '/'
    };

    ImageManager.getVideoClass = function(alpha) {
        if ((Utils.isNwjs() || Utils.isPcChrome()) && !alpha) {
            return Bitmap_Video;
        } else {
            return Bitmap_DrawVideo;
        }
    };

    ImageManager.getVideoFileExt = function() {
        if (Graphics.canPlayVideoType('video/webm')) {
            return '.' + (param.webmExt || 'webm');
        } else {
            return '.' + (param.mp4Ext || 'mp4');
        }
    };

    //=============================================================================
    // SceneManager
    //  戦闘開始時にマップピクチャが一瞬読み込まれてしまう現象を回避します
    //=============================================================================
    SceneManager.isBattleStartUnexpectedLoad = function() {
        return this._scene instanceof Scene_Battle && !$gameParty.inBattle();
    };

    //=============================================================================
    // AudioManager
    //  動画ピクチャの音量を取得します。
    //=============================================================================
    AudioManager._movieVolumePropertyMap = {
        BGM  : 'bgmVolume',
        BGS  : 'bgsVolume',
        ME   : 'meVolume',
        SE   : 'seVolume',
        VOICE: 'voiceVolume'
    };

    AudioManager.getVideoPictureVolume = function(volumeType) {
        var property = this._movieVolumePropertyMap[volumeType];
        return Graphics.getVideoVolume() * (property ? this[property] : 100) / 100;
    };

    //=============================================================================
    // Bitmap
    //  動画かどうかを判定します。
    //=============================================================================
    Bitmap.prototype.isVideo = function() {
        return false;
    };

    /**
     * Bitmap_Video
     * 動画ビットマップクラスです。
     * @constructor
     */
    function Bitmap_Video() {
        this.initialize.apply(this, arguments);
    }

    Bitmap_Video.prototype             = Object.create(Bitmap.prototype);
    Bitmap_Video.prototype.constructor = Bitmap_Video;

    Bitmap_Video.prototype.initialize = function() {
        Bitmap.prototype.initialize.call(this);
    };

    Bitmap_Video.prototype.isVideo = function() {
        return !!this._video;
    };

    Bitmap_Video.load = function(url, smooth, loadClass) {
        var bitmap    = Object.create(loadClass.prototype);
        bitmap._defer = true;
        bitmap.initialize();
        bitmap.smooth = smooth;
        bitmap._requestVideo(url);
        return bitmap;
    };

    Bitmap_Video.prototype.update = function() {
        if (!Utils.isPcChrome()) {
            this._baseTexture.update();
        }
    };

    Bitmap_Video.prototype.setVolume = function(volume) {
        this._video.volume = volume;
    };

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

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

    Bitmap_Video.prototype.destroy = function() {
        if (this.isReady()) {
            this.pause();
            this._video = null;
            this._baseTexture.destroy();
            this.__baseTexture = null;
        } else {
            this._loadingDestory = true;
        }
    };

    Bitmap_Video.prototype._requestVideo = function(url) {
        if (!this._loader) {
            this._loader = ResourceHandler.createLoader(url, this._requestVideo.bind(this, url), this._onError.bind(this));
        }
        this._createVideo(url);
        this._createVideoBaseTexture();
        this._loadingState = 'requesting';
    };

    Bitmap_Video.prototype._createVideo = function(url) {
        this._video     = document.createElement('video');
        this._video.src = url;
        this._video.addEventListener('canplaythrough', this._loadListener = this._onLoad.bind(this));
        this._video.addEventListener('ended', this._endedListener = this._onEnded.bind(this));
        this._video.addEventListener('error', this._errorListener = this._loader || this._onError.bind(this));
        this._video.load();
        this._video.autoplay = false;
        this._loadingState   = 'requesting';
    };

    Bitmap_Video.prototype._createVideoBaseTexture = function() {
        var scaleMode              = this.smooth ? PIXI.SCALE_MODES.LINEAR : PIXI.SCALE_MODES.NEAREST;
        this.__baseTexture         = PIXI.VideoBaseTexture.fromVideo(this._video, scaleMode);
        this._baseTexture.autoPlay = false;
    };

    Bitmap_Video.prototype._onLoad = function() {
        this._loadingState = 'loaded';
        if (!this._video) {
            return;
        }
        if (this._loadingDestory) {
            this.destroy();
            return;
        }
        var width  = this._video.videoWidth;
        var height = this._video.videoHeight;
        this.resize(width, height);
        this._callLoadListeners();
    };

    Bitmap_Video.prototype._onEnded = function() {
        this._firstLapEnded = true;
        if (this._video && !this._video.loop) {
            this._ended = true;
        }
    };

    Bitmap_Video.prototype._onError = function() {
        this._video.removeEventListener('load', this._loadListener);
        this._video.removeEventListener('ended', this._endedListener);
        this._video.removeEventListener('error', this._errorListener);
        this._loadingState = 'error';
    };

    Bitmap_Video.prototype.isFirstLap = function() {
        return !this._firstLapEnded;
    };

    Bitmap_Video.prototype.isEnded = function() {
        return this._ended;
    };

    Bitmap_Video.prototype.setVideoLoop = function(loop) {
        this._video.loop = loop;
    };

    Bitmap_Video.prototype.setCurrentTime = function(value) {
        this._video.currentTime = value;
    };

    Bitmap_Video.prototype.getCurrentTime = function() {
        return this._video.currentTime;
    };

    Bitmap_Video.prototype.setVideoSpeed = function(value) {
        this._video.playbackRate = value;
    };

    /**
     * Bitmap_DrawVideo
     * drawImageで実装する動画ビットマップクラスです。
     * @constructor
     */
    function Bitmap_DrawVideo() {
        this.initialize.apply(this, arguments);
    }

    Bitmap_DrawVideo.prototype             = Object.create(Bitmap_Video.prototype);
    Bitmap_DrawVideo.prototype.constructor = Bitmap_DrawVideo;

    Bitmap_DrawVideo.prototype._createVideoBaseTexture = function() {
        // do nothing
    };

    Bitmap_DrawVideo.prototype.update = function() {
        if (this.isHalfRefreshRateSize() && Graphics.frameCount % 2 !== 0) {
            return;
        }
        if (this.getCurrentTime() > 0) {
            this.clear();
        }
        this._context.drawImage(this._video, 0, 0, this.width, this.height);
        this._baseTexture.update();
    };

    Bitmap_DrawVideo.prototype.isHalfRefreshRateSize = function() {
        return this.width * this.height > 1000000;
    };

    //=============================================================================
    // Graphics
    //  動画の音量を取得します。
    //=============================================================================
    Graphics.getVideoVolume = function() {
        return this._videoVolume;
    };
})();

评分

参与人数 1+1 收起 理由
白嫩白嫩的 + 1 精品文章

查看全部评分

Lv3.寻梦者

梦石
0
星屑
3446
在线时间
1158 小时
注册时间
2016-8-9
帖子
2389

开拓者

2
发表于 2020-9-20 22:44:00 | 只看该作者
1.7.0是不是就不会出现卡在第一帧不动的问题了呢?

点评

那太好了,如果做出游戏有卡住的几率,就在说明里写上【本游戏cg因英特尔和amd处理器罕见漏洞导致出现卡顿几率】  发表于 2020-9-21 14:06
完全不卡住好像是不可能的...我一直重新整理...大約目前是4/5 不會卡住..  发表于 2020-9-21 07:05
應該說...卡住的機率降低很多...哈哈~  发表于 2020-9-21 07:02
酸酸甜甜就④哇噢
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
583
在线时间
281 小时
注册时间
2011-8-31
帖子
101
3
发表于 2020-9-21 09:34:09 | 只看该作者
白嫩白嫩的 发表于 2020-9-20 22:44
1.7.0是不是就不会出现卡在第一帧不动的问题了呢?

一样会卡……

点评

>_<  发表于 2020-9-21 11:00

评分

参与人数 1+1 收起 理由
白嫩白嫩的 + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3446
在线时间
1158 小时
注册时间
2016-8-9
帖子
2389

开拓者

4
发表于 2020-9-21 14:08:09 | 只看该作者

我反复做实验发现如果开了很多其他程序,比如听歌、lol什么的同时再测试游戏会增加卡住的几率,甚至一直没有卡住过的某些视频在这种情况下也会变得非常容易卡住。

然后部署成pc游戏之后可以大幅度减少卡住的几率。

哎,逼死强迫症啊,楼主说跟插件作者沟通过,作者还说没遇到过这问题,难道是打开方式不对?哭

点评

萬歲~ ^_________^  发表于 2020-9-22 07:13
了解,感谢337,测试的时候目前还没出现卡顿,简直太赞了!!  发表于 2020-9-21 22:11
更正: autoEraseOnEnd --> true  发表于 2020-9-21 21:47
在插件選單:autoplay --> true  发表于 2020-9-21 21:44
请问是不是在脚本里面有autoplay的设置都改成true就行了?  发表于 2020-9-21 19:37
酸酸甜甜就④哇噢
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
583
在线时间
281 小时
注册时间
2011-8-31
帖子
101
5
发表于 2020-9-22 14:22:01 | 只看该作者
https://raw.githubusercontent.com/triacontane/RPGMakerMV/master/MoviePicture.js  这个地址打开不了啊,楼上能给个下载地址吗?谢谢啦!!
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
583
在线时间
281 小时
注册时间
2011-8-31
帖子
101
6
发表于 2020-9-22 14:23:06 | 只看该作者
pandeng421 发表于 2020-9-22 14:22
https://raw.githubusercontent.com/triacontane/RPGMakerMV/master/MoviePicture.js  这个地址打开不了啊 ...

不用了,我在https://github.com/triacontane/RPGMakerMV/blob/master/MoviePicture.js上找到了,作者也在这里同步更新了……
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
583
在线时间
281 小时
注册时间
2011-8-31
帖子
101
7
发表于 2020-9-22 14:40:19 | 只看该作者
不过有个新问题,MP_SET_WAIT 这个指令究竟是什么意思啊?用上以后怎么取消WAIT的状态?
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 16:08

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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