Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Event Script not working on 0.7.3 #15682

Closed
Epic-Mawer opened this issue Oct 14, 2024 · 0 comments
Closed

Video Event Script not working on 0.7.3 #15682

Epic-Mawer opened this issue Oct 14, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@Epic-Mawer
Copy link

Describe your problem here.

The event script below works on 0.6.3, but doesn't on 0.7.3. I'm trying to fix it, but it just keeps showing the 'Tried to access a null variable bitmapData' error. If anyone knows how to resolve the error, lemme know:

-- Function to create the video event
function onEvent(name, value1, value2)
if name == "playVideo" then
local videoName = value1 -- The name of the video file is passed as value1

    -- Create a sprite for the video
    makeLuaSprite('videoSprite','',0,0)
    setObjectCamera('videoSprite', 'hud');
    addLuaSprite('videoSprite', false)

    -- Add necessary libraries for video handling
    addHaxeLibrary('MP4Handler','vlc')
    addHaxeLibrary('Event','openfl.events')

    -- Run Haxe code to handle video playback
    runHaxeCode([[
        var filepath = Paths.video(']] .. videoName .. [[');
        var video = new MP4Handler();
        video.playVideo(filepath);
        video.visible = false;
        setVar('video',video);
        FlxG.stage.removeEventListener('enterFrame', video.update); 
    ]])
end

end

function onUpdatePost()
-- Update video frame and handle volume
runHaxeCode([[
var video = getVar('video');
game.getLuaObject('videoSprite').loadGraphic(video.bitmapData);
video.volume = FlxG.sound.volume + 100;
if(game.paused) video.pause();
]])
end

function onResume()
-- Resume video playback when the game is resumed
runHaxeCode([[
var video = getVar('video');
video.resume();
]])
end

Are you modding a build from source or with Lua?

Lua

What is your build target?

Windows x64

Did you edit anything in this build? If so, mention or summarize your changes.

Nope, nothing in source code

@Epic-Mawer Epic-Mawer added the help wanted Extra attention is needed label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants