Skip to content

Commit

Permalink
Play Video Event
Browse files Browse the repository at this point in the history
  • Loading branch information
poec987 committed Jul 18, 2024
1 parent edea279 commit fdfeb73
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

<section if="PRELOAD_ALL">
<library name="songs" preload="true" />
<library name="videos" preload="true" />
<library name="shared" preload="true" />
<library name="tutorial" preload="true" />
<library name="week1" preload="true" />
Expand All @@ -63,6 +64,7 @@

<section if="NO_PRELOAD_ALL">
<library name="songs" preload="false" />
<library name="videos" preload="false" />
<library name="shared" preload="false" />
<library name="tutorial" preload="false" />
<library name="week1" preload="false" />
Expand Down Expand Up @@ -111,6 +113,8 @@

<haxelib name="discord_rpc" if="desktop" />

<haxelib name="hxCodec"/>

<!--In case you want to use the addons package-->
<haxelib name="flixel-addons" />
<haxelib name="hscript" />
Expand All @@ -120,7 +124,9 @@
<haxelib name="newgrounds"/>
<haxelib name="faxe" if='switch'/>
<!--<haxelib name="polymod"/>-->
<!-- <haxelib name="hxcpp-debug-server" if="desktop"/> -->
<haxelib name="hxcpp-debug-server" if="desktop"/>

<haxedef name="HXC_LIBVLC_LOGGING" if="debug" />

<!-- <haxelib name="markdown" /> -->
<!-- <haxelib name="HtmlParser" /> -->
Expand Down Expand Up @@ -160,6 +166,8 @@
<!--Enable this for Nape release builds for a serious peformance improvement-->
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />

<haxedef name='no-deprecation-warnings' />

<!-- _________________________________ Custom _______________________________ -->

<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
Expand Down
Binary file added assets/preload/videos/peak.mp4
Binary file not shown.
Binary file added assets/shared/images/noteTypes/Play Video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions source/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ class ChartingState extends MusicBeatState
"No Animation",
"Play Animation",
"Change Character",
"Play Video",
"Laugh",
"Kill Santa",
"Kill",
Expand Down
10 changes: 10 additions & 0 deletions source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class Note extends FlxSprite
switch (noteType) {
case 'Kill':
loadGraphic(Paths.image('stages/weeb/pixelUI/customNotes/kill-pixels'+suffix), true, 17, 17);
case 'Change Character':
loadGraphic(Paths.image('stages/weeb/pixelUI/customNotes/invis-pixels'+suffix), true, 17, 17);
case 'Play Video':
loadGraphic(Paths.image('stages/weeb/pixelUI/customNotes/invis-pixels'+suffix), true, 17, 17);
default:
loadGraphic(Paths.image('stages/weeb/pixelUI/arrows-pixels'+suffix), true, 17, 17);
}
Expand All @@ -77,6 +81,10 @@ class Note extends FlxSprite
switch (noteType) {
case 'Kill':
loadGraphic(Paths.image('stages/weeb/pixelUI/customNotes/killEnds'+suffix), true, 7, 6);
case 'Change Character':
loadGraphic(Paths.image('stages/weeb/pixelUI/customNotes/invisEnds'+suffix), true, 7, 6);
case 'Play Video':
loadGraphic(Paths.image('stages/weeb/pixelUI/customNotes/invisEnds'+suffix), true, 7, 6);
default:
loadGraphic(Paths.image('stages/weeb/pixelUI/arrowEnds'+suffix), true, 7, 6);
}
Expand All @@ -102,6 +110,8 @@ class Note extends FlxSprite
frames = Paths.getSparrowAtlas('ui/customNotes/kill'+suffix);
case 'Change Character':
frames = Paths.getSparrowAtlas('ui/customNotes/invis'+suffix);
case 'Play Video':
frames = Paths.getSparrowAtlas('ui/customNotes/invis'+suffix);
case 'Shield Note':
frames = Paths.getSparrowAtlas('ui/customNotes/shield'+suffix);
default:
Expand Down
5 changes: 5 additions & 0 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class Paths
return getPath('data/$key.txt', TEXT, library);
}

inline static public function video(key:String, ?library:String)
{
return getPath('videos/$key.mp4', TEXT, library);
}

inline static public function txtImages(key:String, ?library:String)
{
return getPath('images/$key.txt', TEXT, library);
Expand Down
44 changes: 42 additions & 2 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ import Discord.DiscordClient;
import sys.FileSystem;
#end

#if (hxCodec >= "3.0.0") import hxcodec.flixel.FlxVideo as VideoHandler;
#elseif (hxCodec >= "2.6.1") import hxcodec.VideoHandler as VideoHandler;
#elseif (hxCodec == "2.6.0") import VideoHandler;
#else import vlc.MP4Handler as VideoHandler; #end

class PlayState extends MusicBeatState
{
public static var instance(get,null):PlayState;
Expand Down Expand Up @@ -2068,7 +2073,7 @@ class PlayState extends MusicBeatState

noteTypeCheck(daNote, true, true);

if (daNote.noteType != "No Animation" && daNote.noteType != "Laugh" && daNote.noteType != "Play Animation" && daNote.noteType != "Kill Mommy") {
if (daNote.noteType != "No Animation" && daNote.noteType != "Laugh" && daNote.noteType != "Play Animation" && daNote.noteType != "Kill Mommy" && daNote.noteType != "Change Character" && daNote.noteType != "Play Video") {
switch (Math.abs(daNote.noteData))
{
case 2:
Expand Down Expand Up @@ -2212,6 +2217,39 @@ class PlayState extends MusicBeatState
FlxG.switchState(new FreeplayState());
}

public function startVideo(name:String)
{
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;
}

var video:VideoHandler = new VideoHandler();
#if (hxCodec >= "3.0.0")
// Recent versions
video.play(filepath);
video.onEndReached.add(function()
{
video.dispose();
return;
}, true);
#else
// Older versions
video.playVideo(filepath);
video.finishCallback = function()
{
return;
}
#end
}


function endSong():Void
{

Expand Down Expand Up @@ -2768,7 +2806,7 @@ class PlayState extends MusicBeatState
else
health += 0.004;

if (note.noteType != "No Animation" && note.noteType != "Play Animation") {
if (note.noteType != "No Animation" && note.noteType != "Play Animation" && note.noteType != "Change Character" && note.noteType != "Play Video") {
switch (note.noteData)
{
case 2:
Expand Down Expand Up @@ -2849,6 +2887,8 @@ class PlayState extends MusicBeatState
boyfriend = new Boyfriend(pos.x, pos.y, params[1]);
add(boyfriend);
}
case "Play Video":
startVideo(noteTypeParam);
default:
// trace(zeNoteType + "was HITTTEEEEEEEEEEEEED");
}
Expand Down

0 comments on commit fdfeb73

Please sign in to comment.