Skip to content

how to play video from url? #17

Answered by PaulleDemon
zoreu asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @zoreu , if you are looking to play youtube videos, then install pip install pafy and pip install youtube-dl==2020.12.2 <- install this specific version. Now check out the following code:

import pafy

import tkinter as tk
from tkVideoPlayer import TkinterVideo

url = "" #youtube link

video = pafy.new(url)
best = video.getbest(preftype="mp4")

root = tk.Tk()

videoplayer = TkinterVideo(master=root, scaled=True)
videoplayer.load(best.url)
videoplayer.pack(expand=True, fill="both")

videoplayer.play() # play the video

root.mainloop()

If you have any further questions let me know, otherwise mark this as answer.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PaulleDemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #16 on August 28, 2022 22:56.