48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
import vlc
|
|
import time
|
|
|
|
|
|
class Player:
|
|
def __init__(self, video_path):
|
|
# Creating a VLC instance
|
|
player = vlc.Instance()
|
|
# Creating a Media Player
|
|
self.media_player = player.media_player_new()
|
|
# Creating a new Media
|
|
media = player.media_new(video_path)
|
|
# Setting media to media player
|
|
self.media_player.set_media(media)
|
|
|
|
def play(self):
|
|
self.media_player.play()
|
|
|
|
def get_length(self):
|
|
return self.media_player.get_length()
|
|
|
|
def stop(self):
|
|
self.media_player.stop()
|
|
|
|
def get_time(self):
|
|
return self.media_player.get_time()
|
|
|
|
def reset(self):
|
|
self.media_player.set_time(0)
|
|
|
|
# Path to your video file
|
|
if __name__ == '__main__':
|
|
video_path = "/home/wancat/mind-blowing.mp4"
|
|
player = Player(video_path)
|
|
player.play()
|
|
time.sleep(0.1)
|
|
print(player.get_length())
|
|
print(player.get_time())
|
|
time.sleep(5)
|
|
print(player.get_time())
|
|
time.sleep(5)
|
|
print(player.get_time())
|
|
player.reset()
|
|
player.play()
|
|
time.sleep(5)
|
|
player.stop()
|
|
|