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

VideoSprite script help #15305

Closed
Bssez opened this issue Aug 14, 2024 · 2 comments
Closed

VideoSprite script help #15305

Bssez opened this issue Aug 14, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@Bssez
Copy link

Bssez commented Aug 14, 2024

Describe your problem here.

I'm trying to get a video to play in the background of the song while the Hud is still visible. I have this lua file in my 'scripts' folder

--[[
    Made By BBPanzu
    Improved By Cherry
    A Bit Fix By Laztrix


    How To Use:
        Put script in scripts folder
        if you want to use it on a certain script add a local or global variable called video sprite which equals
        dofile("mods/scripts/videoSprite.lua")
        to make the sprite do 

            makeVideoSprite("tag", "path", x, y, "Camera")
        for the camera you can put
            -camHUD
            -camGame
            -other
]]--



-- [[the stuff ]] --
function onCreate()
    addHaxeLibrary('MP4Handler', 'vlc')
    addHaxeLibrary('Event', 'openfl.events')
end
local videoSprites = {}
function makeVideoSprite(tag, videoPath, x, y, camera)
    makeLuaSprite(tag, '', x, y)
    setObjectCamera(tag, camera)
    addLuaSprite(tag, false)
    runHaxeCode([[
        ]]..tag..[[= new MP4Handler();
        ]]..tag..[[.playVideo(CarVideoMissing);
        ]]..tag..[[.visible = false; 
        FlxG.stage.removeEventListener("enterFrame", ]]..tag..[[.update);
        ]]..tag..[[.finishCallback = function()
            { 
                game.getLuaObject("]]..tag..[[").visible = false; 
            }

    ]])
    table.insert(videoSprites, tag)
    --debugPrint('bro the video has been started!')
end
function onUpdatePost()
    for _, __ in pairs(videoSprites) do
        runHaxeCode([[
            if (game.getLuaObject("]]..__..[[") != null)
            {
            game.getLuaObject("]]..__..[[").loadGraphic(]]..__..[[.bitmapData);
            ]]..__..[[.volume = FlxG.sound.volume + 0.4;
            }
        ]])
    end
end
function onPause()
    for _, __ in pairs(videoSprites) do
        runHaxeCode([[
            ]]..__..[[.pause();
        ]])
    end
end
function onResume()
    for _, __ in pairs(videoSprites) do
        runHaxeCode([[
            ]]..__..[[.resume();
        ]])
    end
end`

"CarVideoMissing" is the template video that im trying to get to play with this script, the video is in my 'videos' folder.

In my stage file i have this code:

`function onCreatePost()
    setProperty('boyfriend.visible', false)
    setProperty('gf.visible', false)
    setProperty('dad.visible', false)
    setProperty('healthBar.visible', false)
    setProperty('healthBarBG.visible', false)
    setProperty('iconP1.visible')
    setProperty('iconP2.visible')
end
function onUpdate()
   if canDodge == true and keyJustPressed('enter') then
   pauseVideoSprite('CarVideoMissing')
   end
end
function onSongStart()
    callScript('scripts/videoSprite', 'makeVideoSprite', {'CarVideoMissing', 'CarVideoMissing', -320, -170, 'camHUD'})
    setScrollFactor('Dl', 0, 0)
    scaleObject('CarVideoMissing', 0.65, 0.65)
end`

The video however doesnt play and I only receive this black screen:

image

Any help will be appreciated I am rather lost on what to do/what im missing exactly.

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.

Nothing is edited

@Bssez Bssez added the help wanted Extra attention is needed label Aug 14, 2024
@MaksPRO12667
Copy link

I think it stopped working on Psych Engine 0.7. You may have to use the source code maybe

@ShadowMario
Copy link
Owner

MP4Handler was changed to VideoSprite and its functionality is a bit different

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

3 participants