Python Forum
mpv window freeze before video end
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mpv window freeze before video end
#7
TY - that works! But only when I use it as a standalone.

When I plug it into the function of the (initially posted) script, one of two things happen:
1- if I halt the strem (rightclick) and try to close the window the stream is playing in, the window freezes and I have to close the program from IDLE (or a quit button I have in it).
2- If I let the video/s run through to end, the window closes. But, if I try to select more files via Browse button (activating askopenfilenames()) then the program closes down abruptly as soon as the new file selections are made.
Essentially, this happens with your code and with mine.
I haven't a clue what to try next!

I made a shorter version of the program (removed the other labes/buttons/functions) to it's easier on the eye to look through:

#!/usr/bin/python3

import os
import shutil 
import tkinter as tk 
from tkinter import *
from tkinter import  filedialog, messagebox
from tkinter import ttk

import mpv
player = mpv.MPV(ytdl=True,input_default_bindings=True,input_vo_keyboard=True,osc=True)
media = open('mPlaylist.u3e', 'r').read().splitlines()
# Creating object of tk class 
root = tk.Tk()
root.title("Motion GUI")
root.minsize(width=1000, height=700)
root.maxsize(width=1400, height = 900)

mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N,W,E,S))
root.columnconfigure(0, weight=1)
root.rowconfigure(0,weight=1)

WidgetFrame = ttk.Frame(mainframe, borderwidth=2,relief='ridge',height = 60)
WidgetFrame.grid(column=0,row=0, sticky="E,W")

root.geometry("830x420") 
root.title("View/Copy/Move/Delete mkv's") 
root.config(background = "gray")

def CreateWidgets():
    
    WidgetFrame.link_Label = Label(WidgetFrame, text ="Select File(s): ", bg = "#E8D579") 
    WidgetFrame.link_Label.grid(row = 1, column = 0, pady = 5, padx = 5) 
    
    WidgetFrame.sourceText = Entry(WidgetFrame, width = 50, textvariable = sourceLocation) 
    WidgetFrame.sourceText.grid(row = 1, column = 1, pady = 5, padx = 5, columnspan = 2) 
     
    WidgetFrame.source_browseButton = Button(WidgetFrame, text ="Browse", command = SourceBrowse, width = 15) 
    WidgetFrame.source_browseButton.grid(row = 1, column = 3, pady = 5, padx = 5) 
     
    WidgetFrame.viewButton = Button(WidgetFrame, text ="View File(s)", command = ViewFile, width = 15) 
    WidgetFrame.viewButton.grid(row = 3, column = 0, pady = 5, padx = 5) 

def SourceBrowse(): 
     
    # Opening the file-dialog directory prompting the user to select files to copy using 
    # filedialog.askopenfilenames() method. Setting  initialdir argument is optional Since multiple 
    # files may be selected, converting the selection to list using list() 
    
    WidgetFrame.files_list = list(filedialog.askopenfilenames(initialdir ="/home/rainer/Videos",title="Press shift key plus Left mouse click to select multiple files")) 
    files_list = []
    # Displaying the selected files in the WidgetFrame.sourceText  Entry using WidgetFrame.sourceText.insert() 
    WidgetFrame.sourceText.insert('1', WidgetFrame.files_list)
     
def ViewFile():
    try:
        for item in media:
            player.play(item)
            player.wait_for_playback()
    except mpv.ShutdownError:
        pass
  
# Creating tkinter variable 
sourceLocation = StringVar()
destinationLocation = StringVar()  
files_list = StringVar()

# Calling the CreateWidgets() function 
CreateWidgets() 
     
# Defining infinite loop 
root.mainloop() 
Reply


Messages In This Thread
mpv window freeze before video end - by rfeyer - Feb-13-2021, 10:54 PM
RE: mpv window freeze before video end - by nilamo - Feb-15-2021, 08:52 PM
RE: mpv window freeze before video end - by rfeyer - Feb-16-2021, 03:11 AM
RE: mpv window freeze before video end - by rfeyer - Feb-16-2021, 01:11 PM
RE: mpv window freeze before video end - by rfeyer - Feb-16-2021, 09:55 PM
RE: mpv window freeze before video end - by rfeyer - Feb-17-2021, 12:07 AM
RE: mpv window freeze before video end - by rfeyer - Feb-17-2021, 12:12 AM
RE: mpv window freeze before video end - by rfeyer - Feb-17-2021, 11:02 AM
RE: mpv window freeze before video end - by rfeyer - Feb-17-2021, 12:54 PM
RE: mpv window freeze before video end - by rfeyer - Feb-17-2021, 01:55 PM
RE: mpv window freeze before video end - by rfeyer - Feb-17-2021, 04:32 PM
RE: mpv window freeze before video end - by rfeyer - Mar-07-2021, 12:49 PM
RE: mpv window freeze before video end - by rfeyer - Mar-09-2021, 06:12 PM
RE: mpv window freeze before video end - by nilamo - Mar-09-2021, 04:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,966 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Tkinter + Multiprocessing startmap makes UI Freeze sunny9495 4 1,493 Nov-13-2022, 12:49 PM
Last Post: sunny9495
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,219 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Install Python 3.8 for EduPython and Cx-Freeze mederic39 1 1,833 Jul-24-2020, 01:24 PM
Last Post: Larz60+
  Cx Freeze to exe - HELP WBPYTHON 5 3,945 Apr-09-2020, 01:34 PM
Last Post: WBPYTHON
  A software freeze ! HELP ! redorc15 1 1,822 Oct-10-2019, 10:54 PM
Last Post: Larz60+
  cx-Freeze exe doesn't work ammann 1 4,348 Mar-19-2018, 10:58 AM
Last Post: buran
  Pyusb freeze when using Dev.read(nr,nr,timeout=1000) bojane 3 7,591 Jan-11-2017, 10:17 AM
Last Post: bojane

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020