Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- #Copyright Kris Occhipinti 01/16/2021
- #https://filmsbykris.com
- #Licensed under the GPLv3
- func _ready():
- #load and play random video
- var video = get_random_video()
- var player = create_video_player(video,self)
- func create_video_player(video,parent):
- var player = VideoPlayer.new()
- parent.add_child(player)
- player.set_size(get_viewport_rect().size)
- video = load(video)
- player.stream = video
- player.play()
- return player
- func get_random_video():
- var videos = search_files(".",".ogv")
- randomize()
- videos.shuffle()
- return videos[0]
- func search_files(path,ext):
- var files = []
- var dir = Directory.new()
- dir.open(path)
- dir.list_dir_begin()
- while true:
- var file = dir.get_next()
- if file == "":
- break
- elif file.ends_with(ext):
- files.append(file)
- dir.list_dir_end()
- return files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement