Skip to content

Commit

Permalink
Changed from hxCodec to hxvlc
Browse files Browse the repository at this point in the history
Yeah i'm a bad coder, but i tried my best!

I'll let ya guys do the rest of the work, i did what i did.

-Lunar
  • Loading branch information
SyncGit12 committed Jan 11, 2025
1 parent 6de6d9c commit 90e855e
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 46 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Lime",
"type": "lime",
"request": "launch"
}
]
}
6 changes: 5 additions & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@
<haxelib name="hscript" />
<haxedef name="hscriptPos" />
<haxelib name="linc_luajit" if="LUA_ALLOWED"/>
<haxelib name="hxCodec" if="VIDEOS_ALLOWED"/>
<!--<haxelib name="hxCodec" if="VIDEOS_ALLOWED"/>-->

<section if="cpp">
<haxelib name="hxvlc" if="VIDEOS_ALLOWED" /> <!--Welcome home, hxvlc!-->
</section>

<haxelib name="hxdiscord_rpc" if="DISCORD_ALLOWED" />
<haxelib name="flxanimate"/>
Expand Down
8 changes: 5 additions & 3 deletions hmm.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
"url": "https://github.com/HaxeFoundation/hxcpp"
},
{
"name": "hxCodec",
"type": "haxelib",
"version": "2.5.1"
"name": "hxvlc",
"type": "git",
"dir": null,
"ref": "main",
"url": "https://github.com/MAJigsaw77/hxvlc"
},
{
"name": "hscript",
Expand Down
2 changes: 1 addition & 1 deletion setup/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ haxelib install hscript
haxelib install hxcpp-debug-server
haxelib git away3d https://github.com/moxie-coder/away3d
haxelib git hxcpp https://github.com/HaxeFoundation/hxcpp/
haxelib git hxCodec https://github.com/polybiusproxy/hxCodec
haxelib git flxanimate https://github.com/Dot-Stuff/flxanimate 768740a56b26aa0c072720e0d1236b94afe68e3e
haxelib git linc_luajit https://github.com/superpowers04/linc_luajit.git
haxelib git funkin.vis https://github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90
haxelib git grig.audio https://gitlab.com/haxe-grig/grig.audio.git cbf91e2180fd2e374924fe74844086aab7891666
haxelib git hxdiscord_rpc https://github.com/MAJigsaw77/hxdiscord_rpc
haxelib git hxvlc https://github.com/MAJigsaw77/hxvlc
echo Finished!
2 changes: 1 addition & 1 deletion setup/windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ haxelib install flixel 5.6.2
haxelib install flixel-addons 3.2.3
haxelib install flixel-tools 1.5.1
haxelib install flixel-ui 2.6.1
haxelib install hxCodec 2.5.1
haxelib install hscript
haxelib install hxcpp-debug-server
haxelib git away3d https://github.com/moxie-coder/away3d
Expand All @@ -20,6 +19,7 @@ haxelib git linc_luajit https://github.com/superpowers04/linc_luajit
haxelib git funkin.vis https://github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90
haxelib git grig.audio https://gitlab.com/haxe-grig/grig.audio.git cbf91e2180fd2e374924fe74844086aab7891666
haxelib git hxdiscord_rpc https://github.com/MAJigsaw77/hxdiscord_rpc
haxelib git hxvlc https://github.com/MAJigsaw77/hxvlc
@echo off
echo Finished!
pause
82 changes: 58 additions & 24 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,11 @@ import flixel.addons.display.FlxRuntimeShader;
import openfl.filters.ShaderFilter;
#end

#if VIDEOS_ALLOWED
#if (hxCodec >= "3.0.0" || hxCodec == "git")
import hxcodec.flixel.FlxVideo as MP4Handler;
#elseif (hxCodec == "2.6.1")
import hxcodec.VideoHandler as MP4Handler;
#elseif (hxCodec == "2.6.0")
import VideoHandler as MP4Handler;
#else
import vlc.MP4Handler;
#end
#if VIDEOS_ALLOWED // Modify if i drunk coffee and fucked up! - SyncGit12
import hxvlc.flixel.FlxVideo;
import hxvlc.flixel.FlxVideoSprite;
import hxvlc.util.Handle;
import hxvlc.openfl.Video;
#end

import Note;
Expand Down Expand Up @@ -1929,7 +1924,10 @@ class PlayState extends MusicBeatState
char.y += char.positionArray[1];
}

var videoCutscene:MP4Handler = null;
/***************/
/* VIDEO */
/***************/
var videoCutscene:FlxVideoSprite = null;
public function startVideo(name:String, ?callback:Void->Void = null)
{
#if VIDEOS_ALLOWED
Expand All @@ -1943,16 +1941,52 @@ class PlayState extends MusicBeatState
#end
{
FlxG.log.warn('Couldnt find video file: ' + name);
if (callback != null)
callback();
return;
}

videoCutscene = new FlxVideoSprite(0, 0);
videoCutscene.active = false;
videoCutscene.antialiasing = true;
videoCutscene.bitmap.onFormatSetup.add(function():Void
{
if (video.bitmap != null && video.bitmap.bitmapData != null)
{
final scale:Float = Math.min(FlxG.width / video.bitmap.bitmapData.width, FlxG.height / video.bitmap.bitmapData.height);

videoCutscene.setGraphicSize(video.bitmap.bitmapData.width * scale, video.bitmap.bitmapData.height * scale);
videoCutscene.updateHitbox();
videoCutscene.screenCenter();
}
});
videoCutscene.bitmap.onEndReached.add(videoCutscene.destroy);
//#if (hxCodec < "3.0.0")
videoCutscene.load(filepath);

public function startAndEnd()
{
if(endingSong)
endSong();
else
startAndEnd();
startCountdown();
}

// Lily, if you're reading this, copy this to the mobile branch, thanks! - SyncGit12
/*#if mobile
final file:String = FileSystem.readDirectory('./')[0];
#else
final file:String = haxe.io.Path.join(['Paths.video', FileSystem.readDirectory('Paths.video')[0]]);
#end*/

trace('This might not work! YAY :DDDDD');

if (file != null && file.length > 0)
video.load(file);
else
{
return;
}

videoCutscene = new MP4Handler();
#if (hxCodec < "3.0.0")
videoCutscene.playVideo(filepath);
/*
if (callback != null)
videoCutscene.finishCallback = callback;
else{
Expand All @@ -1963,22 +1997,22 @@ class PlayState extends MusicBeatState
return;
}
}
*/

add(videoCutscene);

#else
videoCutscene.play(filepath);
if (callback != null)
videoCutscene.onEndReached.add(callback);
return; // Might crash the game btw
else{
videoCutscene.onEndReached.add(function(){
startAndEnd();
if (heyStopTrying) openfl.system.System.exit(0);
return;
});
return; // Might crash the game btw
}
#end
#else
FlxG.log.warn('Platform not supported!');
if (callback != null)
callback();
return;
else
startAndEnd();
return;
Expand Down
125 changes: 109 additions & 16 deletions source/StartupState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ package;

import flixel.input.keyboard.FlxKey;

#if VIDEOS_ALLOWED
#if (hxCodec >= "3.0.0" || hxCodec == "git")
import hxcodec.flixel.FlxVideo as MP4Handler;
#elseif (hxCodec == "2.6.1")
import hxcodec.VideoHandler as MP4Handler;
#elseif (hxCodec == "2.6.0")
import VideoHandler as MP4Handler;
#else
import vlc.MP4Handler;
#end
#if VIDEOS_ALLOWED // Modify if i drunk coffee and fucked up! - SyncGit12
import hxvlc.flixel.FlxVideo;
import hxvlc.flixel.FlxVideoSprite;
import hxvlc.util.Handle;
import hxvlc.openfl.Video;
#end

class StartupState extends MusicBeatState
Expand All @@ -24,6 +19,104 @@ class StartupState extends MusicBeatState

var canChristmas = false;

public function startVideo(name:String, ?callback:Void->Void = null)
{
#if VIDEOS_ALLOWED
inCutscene = true;

var filepath:String = Paths.video(name);
#if sys
if(!FileSystem.exists(filepath))
#else
if(!OpenFlAssets.exists(filepath))
#end
{
FlxG.log.warn('Couldnt find video file: ' + name);
return;
}

vidSprite = new FlxVideoSprite(0, 0);
vidSprite.active = false;
vidSprite.antialiasing = true;
vidSprite.bitmap.onFormatSetup.add(function():Void
{
if (video.bitmap != null && video.bitmap.bitmapData != null)
{
final scale:Float = Math.min(FlxG.width / video.bitmap.bitmapData.width, FlxG.height / video.bitmap.bitmapData.height);

vidSprite.setGraphicSize(video.bitmap.bitmapData.width * scale, video.bitmap.bitmapData.height * scale);
vidSprite.updateHitbox();
vidSprite.screenCenter();
}
});
vidSprite.bitmap.onEndReached.add(vidSprite.destroy);
//#if (hxCodec < "3.0.0")
vidSprite.load(filepath);

/*public function startAndEnd()
{
if(endingSong)
endSong();
else
startCountdown();
}*/

/*public function goToTitle()
{
FlxG.switchState(TitleState.new);
super.update(elapsed);
}*/


// Lily, if you're reading this, copy this to the mobile branch, thanks! - SyncGit12
/*#if mobile
final file:String = FileSystem.readDirectory('./')[0];
#else
final file:String = haxe.io.Path.join(['Paths.video', FileSystem.readDirectory('Paths.video')[0]]);
#end*/

trace('This might not work! YAY :DDDDD');

if (file != null && file.length > 0)
video.load(file);
else
{
return;
}

/*
if (callback != null)
vidSprite.finishCallback = callback;
else{
vidSprite.finishCallback = function()
{
startAndEnd();
if (heyStopTrying) openfl.system.System.exit(0);
return;
}
}
*/

add(vidSprite);

#else
vidSprite.load(filepath);
if (callback != null)
return; // Might crash the game btw
else{
return; // Might crash the game btw
}
#end
#else
FlxG.log.warn('Platform not supported!');
if (callback != null)
return; // Might crash the game btw
else
return; // Might crash the game btw
return;
#end
}

override public function create():Void
{
#if VIDEOS_ALLOWED maxIntros += 2; #end
Expand Down Expand Up @@ -124,17 +217,16 @@ class StartupState extends MusicBeatState
FlxTween.tween(logo, {alpha: 1, "scale.x": 1, "scale.y": 1}, 1.35, {ease: FlxEase.expoOut, onComplete: _ -> onIntroDone(0.6)});
case 4:
#if VIDEOS_ALLOWED
var vidSprite = new MP4Handler(); // it plays but it doesn't show???
#if (hxCodec < "3.0.0")
vidSprite.playVideo(Paths.video('bambiStartup', 'splash'), false, false);
var vidSprite = new FlxVideoSprite(); // it plays but it doesn't show??
vidSprite.load(Paths.video('bambiStartup', 'splash'));
vidSprite.finishCallback = function()
{
try { vidSprite.dispose(); }
catch (e) {}
FlxG.switchState(TitleState.new);
};
#else
vidSprite.play(Paths.video('bambiStartup', 'splash'));
vidSprite.load(Paths.video('bambiStartup', 'splash'));
vidSprite.onEndReached.add(function(){
vidSprite.dispose();
FlxG.switchState(TitleState.new);
Expand All @@ -145,15 +237,16 @@ class StartupState extends MusicBeatState
#if VIDEOS_ALLOWED
var vidSprite = new MP4Handler(); // it plays but it doesn't show???
#if (hxCodec < "3.0.0")
vidSprite.playVideo(Paths.video('broCopiedDenpa', 'splash'), false, false);
var vidSprite = new FlxVideoSprite(); // it plays but it doesn't show??
vidSprite.load(Paths.video('broCopiedDenpa', 'splash'));
vidSprite.finishCallback = function()
{
try { vidSprite.dispose(); }
catch (e) {}
FlxG.switchState(TitleState.new);
};
#else
vidSprite.play(Paths.video('broCopiedDenpa', 'splash'));
vidSprite.load(Paths.video('broCopiedDenpa', 'splash'));
vidSprite.onEndReached.add(function(){
vidSprite.dispose();
FlxG.switchState(TitleState.new);
Expand Down

0 comments on commit 90e855e

Please sign in to comment.