-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 48 additions & 1 deletion
49
src/docs/Modding The Engine/Scripting/Using hxvlc for videos.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,48 @@ | ||
# Using hxvlc for videos | ||
# Using hxvlc for videos | ||
|
||
Using hxvlc, you can display videos anywhere, and can be used as a sprite as well. | ||
|
||
To get started, you get 2 choices: | ||
- ``FlxVideo`` which runs based on flash bitmap, and | ||
- ``FlxSpriteVideo`` which runs based on an FlxSprite. | ||
|
||
Using an FlxVideo looks something like this: | ||
```hx | ||
var video:FlxVideo = new FlxVideo(); | ||
video.onEndReached.add(function():Void | ||
{ | ||
video.dispose(); | ||
FlxG.removeChild(video); | ||
}); | ||
FlxG.addChildBelowMouse(video); | ||
if (video.load(Paths.video("video"))) | ||
new FlxTimer().start(0.001, (_) -> video.play()); | ||
``` | ||
And using an FlxVideoSprite looks like this: | ||
```hx | ||
var video:FlxVideoSprite = new FlxVideoSprite(0, 0); | ||
video.antialiasing = true; | ||
video.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); | ||
video.setGraphicSize(video.bitmap.bitmapData.width * scale, video.bitmap.bitmapData.height * scale); | ||
video.updateHitbox(); | ||
video.screenCenter(); | ||
} | ||
}); | ||
video.bitmap.onEndReached.add(video.destroy); | ||
add(video); | ||
if (video.load(Paths.video("video"))) | ||
new FlxTimer().start(0.001, (_) -> video.play()); | ||
``` | ||
These will load the video ``./videos/video.mp4``, and display it on the screen. | ||
|
||
Other thing to note is that when you type ``Paths.video("video")``, keep in mind that you can write the extension next to the path, which let's you load filetypes other than .mp4. | ||
|
||
*(btw tiny thing to also note is that if your video suffers from huge filesize i recommend using .webm instead of .mp4)* |