Repeating single movie using Python bindings for VLC: what is a psz_name - vlc

I'm trying to write an little application that dynamically plays a single movie file repeatedly. I wrote it in Python, using these VLC-Python bindings
I would say that this wouldn't be so hard and even though the very sparse documentation I can get a movie fullscreen without anything else on the screen and even change the file I want to play. What I cannot is simply let a single movie repeat.
I use the following code:
self.media = []
A --repeat-tag here:
self.vlc_inst = vlc.Instance('--mouse-hide-timeout=0', '--fullscreen', '--repeat')
And a '--repeat' tag here:
self.media = self.vlc_inst.media_new(NEW_VIDEO_NAME + str(currentVideoN) + VIDEO_EXTENSION, '--repeat')
self.player = self.vlc_inst.media_player_new()
self.player.set_fullscreen(True)
self.player.set_media(self.media[currentVideoN])
self.player.play()
These repeat tags don't seem to do anything. The Instance class does have a function vlm_set_loop(self, psz_name, b_loop) but I have no idea what mrl should be. In the original code I figured out it should be a char-array (String), but I have no clue what kind of String this should be.
Anyone who does have a clue?

well, this question is pretty old, but anyways... i think instead of using '--repeat' (which only works with a medialist rather than a single mediafile afaik) in your vlc.Instance you could use somthing like '--input-repeat=999999' it's not really a loop, but as close as it gets (again: afaik ;-) )

I was able to make the media replay by setting the media to it's current media and calling play. Is the code trash? Yes, it is: the back function may not be called inside the onEnd function, else i won't full fill by some reason. Does it work? Yes
import vlc
doTrashCode = False
player = vlc.MediaPlayer("C:/Users/benj5/Videos/2019-04-29 22-14-55_Trim.mp4")
def start():
player.set_fullscreen(True)
em = player.event_manager()
em.event_attach(vlc.EventType.MediaPlayerEndReached, onEnd)
player.play()
def onEnd(event):
global doTrashCode
if event.type == vlc.EventType.MediaPlayerEndReached:
doTrashCode = True
def back():
player.set_media(player.get_media())
player.play()
start()
while True:
if doTrashCode:
back()
doTrashCode = False

you can use subprocess
p = subprocess.Popen('cvlc', 'fullscreen', 'home/pi/demo.mp4', '--loop')
I used VLC instead of CVLC earlier but it wasn't working fine for me, it was reloading and resizing the VLC player when the loop end

Related

Lua audio script for roblox isnt working?

my friend made a script for a club game and the audio seems to not work please help
local playlist = {4773093598, 727844285}
local mubic = game.Workspace.moosesack
local G_egg = true
while G_egg == true do
for i, v in ipairs(playlist) do
mubic.SoundId = v
mubic:Play()
wait(mubic.TimeLength)
end
end
Why are you trying to assign multiple Audio ID’s to a single Sound Instance at one time?
To create a functioning music playlist, you would need to create a queue.
And also, because you are using a while loop you are exhausting the Lua thread processor, you would need to add wait().
Furthermore, the while loop is an actual loop, so it will execute the same code infinitely until your boolean switches to false.
From the information that you've given ("seems to not work"), there is 1 error in your code.
mubic.SoundId = v
What the code is being read as is "mubic.SoundId = 4773093598"
To roblox, this is not correct as the SoundId must be defined as a string and as an asset id. Your code should look like:
local playlist = {4773093598, 727844285}
local mubic = game.Workspace.moosesack
local G_egg = true
while G_egg == true do
for i, v in ipairs(playlist) do
mubic.SoundId = "rbxassetid://"..tostring(v)
mubic:Play()
wait(mubic.TimeLength)
end
end

How do I make this code function correctly?

I want to make a sort of Lobby system in Roblox Studio where if you have 4 people on a part you get sent to another place. I tried to set up a system for it, but it didn't work; can you help me through this?
I've tried making it so it says .Value at the end.
local TeleportService = game:GetService("TeleportService")
player_amount = script.Parent.Parent.Parent.Player_Count
local placeID_1 = 4119652438
local function onPartTouch(otherPart)
local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
player_amount.Value = player_amount.Value + 1
end
if player_amount == 4 then
TeleportService:Teleport(placeID_1, player)
end
end
script.Parent.Touched:Connect(onPartTouch)
I expected the output to be 0 then if one person steps on it, it would update the sign to say 1. But it only stays at 0.
This is not a viable solution as .Touched fires every frame the player touches a part, and only when they move. I suggest creating a hitbox, as I have done here

How can My GUI appear when my noob is killed?

[My code is :]
local function MWin()
game.StarterGui.ScreenGui1.DemonWin.Visible = true
if game.Workspace.Mages_Boss.Humanoid.Died:connect(function()
print("good")
end
[My noob is named : Mages_Boss
And my screen gui is named : DemonWin
I dont know what to put for "print("good")".]
First, modifying the starter GUI does nothing. You need to change the one player or all players with a for loop. In my answer, I’ll use the former with a player named ROBLOX. If you want to start with it invisible, you need game.Players.ROBLOX.PlayerGui.ScreenGui1.DemonWin.Visible = false. To make it visible on the death event, use game.Players.ROBLOX.PlayerGui.ScreenGui1.DemonWin.Visible = true.
Try using
DemonWin.Enabled=true;
or
DemonWin.Enabled=false;
to toggle whether it is active or not. I suppose in the died function, use the latter.
I'm going to assume you're not firing the function so you can get rid of that. You're also going to remove the .Died since it fires even when it's not dead. So your best bet would be to do also add a debounce- kind of function to your script. Here's the modified version:
game.StarterGui.ScreenGui1.DemonWin.Visible = false
if game.Workspace.Mages_Boss.Humanoid.Health == 0 then
game.StarterGui.ScreenGui1.DemonWin.Visible = true
else
game.StarterGui.ScreenGui1.DemonWin.Visible = false
end
Also, you would have to put the GUI in the StarterGui (located in game.Players.LocalPlayer.StarterGui) in order to not publicly malfunction this script.

GMOD Lua Use type doesn't matter?

recently I have been creating an imitation HarborRP gamemode for Garry's Mod, and I'm trying to recreate the Smuggler NPC (You'll know what I mean if you've ever played HarborRP) So basically I want the NPC to open ONE Derma-Frame window when the player presses their use key on it. I have the NPC created and all of that, but when the player simply presses their use key on the NPC, a million windows pop up, I have the NPC/Entity's use type set to SIMPLE_USE, but it seems like that doesn't matter because so many windows pop up. the VGUI/Derma Frame's settings is set to MakePopup() but that doesn't matter either. See if you can find whats wrong with it, I have very little knowledge of LUA.
init.lua file:
include("shared.lua")
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
util.AddNetworkString("smug")
hook.Add("PlayerUse", "menuu", function(ply, ent)
net.Start("smug")
net.Send(ply)
end)
function ENT:Initialize()
self:SetModel('models/humans/group01/female_01.mdl')
self:SetHullType(HULL_HUMAN)
self:SetHullSizeNormal()
self:SetNPCState(NPC_STATE_SCRIPT)
self:SetSolid(SOLID_BBOX)
self:SetUseType(SIMPLE_USE)
self:DropToFloor()
end
cl_init.lua file:
include("shared.lua")
function ENT:Draw()
self.Entity:DrawModel()
end
net.Receive("smug", function()
if( !frame ) then
local frame = vgui.Create("DFrame")
frame:SetSize(900,600)
frame:SetPos(ScrW()/2-450,ScrH()/2-300)
frame:SetVisible(true)
frame:MakePopup()
frame:SetDeleteOnClose(true)
elseif (frame) then print("HI")
end
end)
shared.lua file:
ENT.Base = "base_ai"
ENT.Type = "ai"
ENT.PrintName = "[DEV] Smuggler NPC"
ENT.Category = "InVaLiD's HBRP Entities"
ENT.Author = "InVaLiD"
ENT.Spawnable = true
ENT.AdminSpawnable = true
ENT.AutomaticFrameAdvance = true
Something To Note
All of these files are in the addons/smug_npc/lua/entities/ folder.
Yes, I know I have weird names for things, that's just me.
I have a basic to no knowledge of lua, so explain things please :)
I really do appreciate your help, and your will to help people, please know that I thank you all for being here just to sort other people's problems even though you could be spending your time doing something productive, Thank you!
You need to put your code that does net.Send into the entities ENT:Use function rather than on the PlayerUse hook.
function ENT:Use(ply)
net.Start("smug")
net.Send(ply)
end
The below line which you already have in your code in the initialize function makes the entity call the ENT:Use function once when a player presses E on it, which it seems that you want to do so that is good:
self:SetUseType(SIMPLE_USE)
Also, I recommend checking out the gmod forums if you need developer help in future.
GMod forums: https://gmod.facepunch.com/f

In Lua, using a boolean variable from another script in the same project ends up with nill value error

This code is for a modding engine, Unitale base on Unity Written in Lua
So I am trying to use a Boolean Variable in my script poseur.lua, so when certain conditions are met so I can pass it to the other script encounter.lua, where a engine Predefined functions is being uses to make actions happens base on the occurring moment.
I tried to read the engine documentation multiple times, follow the exact syntax of Lua's fonction like GetVar(), SetVar(), SetGobal(),GetGlobal().
Searching and google thing about the Language, post on the subreddit and Game Exchange and tried to solve it by myself for hours... I just can't do it and I can't understand why ?
I will show parts of my codes for each.
poseur:
-- A basic monster script skeleton you can copy and modify for your own creations.
comments = {"Smells like the work\rof an enemy stand.",
"Nidhogg_Warrior is posing like his\rlife depends on it.",
"Nidhogg_Warrior's limbs shouldn't\rbe moving in this way."}
commands = {"GREET", "JUMP", "FLIRT", "CRINGE"}
EndDialougue = {" ! ! !","ouiii"}
sprite = "poseur" --Always PNG. Extension is added automatically.
name = "Nidhogg_Warrior"
hp = 99
atk = 1
def = 1
check = "The Nidhogg_Warrior is\rsearching for the Nidhogg"
dialogbubble = "rightlarge" -- See documentation for what bubbles you have available.
canspare = false
cancheck = true
GreetCounter = 5
Berserk = false
encounter:
-- A basic encounter script skeleton you can copy and modify for your own creations.
encountertext = "Nidhogg_Warrior is\rrunning frantically"
nextwaves = {"bullettest_chaserorb"}
wavetimer = 5.0
arenasize = {155, 130}
music = "musAncientGuardian"
enemies = {"poseur"}
require("Monsters.poseur")
enemypositions = {{0, 0}}
-- A custom list with attacks to choose from.
-- Actual selection happens in EnemyDialogueEnding().
-- Put here in case you want to use it.
possible_attacks = {"bullettest_bouncy", "bullettest_chaserorb", "bullettest_touhou"}
function EncounterStarting()
-- If you want to change the game state immediately, this is the place.
Player.lv = 20
Player.hp = 99
Player.name = "Teemies"
poseur.GetVar("Berserk")
end
Thank you for reading.
The answer to my problem was to use SetGobal(), GetGobal().
For some reasons my previous attempt to simply use SetGobal()Resulted in nil value despite writing it like that SetGobal("Berserk",true) gave me a nill value error, as soon as I launch the game.
But I still used them wrong. First I needed to put it SetGobal() at the end of the condition instead of at the start of the the poseur.lua script because the change of value... for some reasons was being overwritten by it first installment.
And to test the variable in the function in my encounter.lua, I needed to write it like that
function EnemyDialogueStarting()
-- Good location for setting monster dialogue depending on how the battle is going.
if GetGlobal("Jimmies") == true then
TEEEST()
end
end
Also any tips an suggestions are still welcome !
Well firstly, in lua simple values like bool and number are copied on assignment:
global={}
a=2
global.a=a--this is a copy
a=4--this change won't affect value in table
print(global.a)--2
print(a)--4
Secondly,
SetGobal and the other mentioned functions are not part of lua language, they must be related to your engine. Probably, they use word 'Global' not as lua 'global' but in a sense defined by engine.
Depending on the engine specifics these functions might as well do a deep copy of any variable they're given (or might as well not work with complicated objects).

Resources