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

[ENHANCEMENT] Add polymod support by getting file path from OpenFL assets #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/hxcodec/flixel/FlxVideo.hx
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import flixel.FlxG;
import hxcodec.openfl.Video;
import openfl.events.Event;
import sys.FileSystem;
import openfl.utils.Assets;

class FlxVideo extends Video
{
@@ -39,7 +40,9 @@ class FlxVideo extends Video

FlxG.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);

if (FileSystem.exists(Sys.getCwd() + location))
if (Assets.exists(location))
return super.play(Assets.getPath(location), shouldLoop);
else if (FileSystem.exists(Sys.getCwd() + location))
return super.play(Sys.getCwd() + location, shouldLoop);
else
return super.play(location, shouldLoop);
11 changes: 7 additions & 4 deletions src/hxcodec/flixel/FlxVideoBackdrop.hx
Original file line number Diff line number Diff line change
@@ -4,10 +4,11 @@ package hxcodec.flixel;
#if (!flixel_addons && macro)
#error 'Your project must use flixel-addons in order to use this class.'
#end

import flixel.FlxG;
import flixel.util.FlxAxes;
import flixel.addons.display.FlxBackdrop;
import openfl.utils.Assets;

import sys.FileSystem;
import hxcodec.openfl.Video;
@@ -53,10 +54,12 @@ class FlxVideoBackdrop extends FlxBackdrop

if (bitmap != null)
{
if (FileSystem.exists(Sys.getCwd() + location))
if (Assets.exists(location))
return bitmap.play(Assets.getPath(location), shouldLoop);
else if (FileSystem.exists(Sys.getCwd() + location))
return bitmap.play(Sys.getCwd() + location, shouldLoop);

return bitmap.play(location, shouldLoop);
else
return bitmap.play(location, shouldLoop);
}

return -1;
5 changes: 4 additions & 1 deletion src/hxcodec/flixel/FlxVideoSprite.hx
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ package hxcodec.flixel;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.util.FlxColor;
import openfl.utils.Assets;

import sys.FileSystem;
import hxcodec.openfl.Video;
@@ -50,7 +51,9 @@ class FlxVideoSprite extends FlxSprite

if (bitmap != null)
{
if (FileSystem.exists(Sys.getCwd() + location))
if (Assets.exists(location))
return bitmap.play(Assets.getPath(location), shouldLoop);
else if (FileSystem.exists(Sys.getCwd() + location))
return bitmap.play(Sys.getCwd() + location, shouldLoop);
else
return bitmap.play(location, shouldLoop);