-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideoplayerlogic.py
More file actions
46 lines (38 loc) · 2.96 KB
/
videoplayerlogic.py
File metadata and controls
46 lines (38 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import VideoplayerUi
import vlc
import pafy
import sys
import videodatabase
from PyQt5 import QtCore, QtGui, QtWidgets
class VideoPlayerLogic:
def __init__(self):
self.videoplayerui=VideoplayerUi.VideoPlayer()
self.instance = vlc.Instance()
self.mediaplayer = self.instance.media_player_new()
if sys.platform.startswith("linux"): # for Linux using the X Server
self.mediaplayer.set_xwindow(self.videoplayerui.videoframe.winId())
elif sys.platform == "win32": # for Windows
self.mediaplayer.set_hwnd(self.videoplayerui.videoframe.winId())
elif sys.platform == "darwin": # for MacOS
self.mediaplayer.set_nsobject(self.videoplayerui.videoframe.winId())
def asdf(self):
self.videodata=videodatabase.VideoData()
self.videoplayerui.mainwindow.show()
url = "https://www.youtube.com/watch?v=h4iGKoTZ4iM"
video = pafy.new(url)
best = video.getbest()
playurl = best.url
media = self.instance.media_new(playurl)
self.mediaplayer.set_media(media)
self.mediaplayer.play()
print('asdf')
# import pafy
# import vlc
# #
# #
# url = "https://www.youtube.com/watch?v=G0OqIkgZqlA"
# video = pafy.new(url)
# best = video.getbestaudio()
# playurl = best.url
# player = vlc.MediaPlayer(playurl)
# player.play()