Giter VIP home page Giter VIP logo

yjg30737 / pyqt-graphics-video-item-video-player Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 1.0 43 KB

Video(mp4 file only) player using QGraphicsVideoItem. Control widget at the bottom is shown/hidden followed by cursor's movement.

License: MIT License

Python 94.77% CSS 5.23%
pyqt5-video-player pyqt-video-player pyqt5-gui pyqt5-desktop-application pyqt5-application pyqt5-examples pyqt5-tutorial pyqt-examples pyqt-tutorial pyqt5

pyqt-graphics-video-item-video-player's Introduction

pyqt-graphics-video-item-video-player

Video(mp4 file only) player using QGraphicsVideoItem. Control widget at the bottom is shown/hidden followed by cursor's movement.

Note: You need K-Lite Codec to play the video with this.

Requirements

PyQt5 >= 5.8

Setup

python -m pip install git+https://github.com/yjg30737/pyqt-graphics-video-item-video-player --upgrade

Included Packages

Usage

This video player is mp4 only.

You can set the video file by dropping it to the window. That is the only way.

Example

Code Sample

from PyQt5.QtWidgets import QApplication
from pyqt_graphics_video_item_video_player.videoPlayer import VideoPlayer

if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    videoPlayer = VideoPlayer()
    videoPlayer.show()
    app.exec_()

Result

1. Preview of interaction between cursor movement and control widget visibility

example.mp4

Control widget is going to show when

  • The cursor enters into the window
  • The cursor stays on the control widget
  • The cursor moves again

Control widget is going to hide when

  • The cursor leaves from the window
  • The cursor stays outside of the control widget

2. Preview of watching video with the pyqt-graphics-video-item-video-player and using control widget to navigate the video (Example video is result video of pyqt-find-replace-text-widget.) (Note: Style of slider and buttons are set to old version in the example.)

example.mp4

Note

QGraphicsVideoItem's video quality is worse than QVideoWidgets.

You maybe wonder why did i make this in the first place.

Because for some reasons, I can't show the control widget (which has transparent background) over the QVideoWidget.

I'm still trying to figure out the way to solve this problem.

One more thing, There are some flaws in timer feature and button toggling. I will fix it.

pyqt-graphics-video-item-video-player's People

Contributors

yjg30737 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

nikonru

pyqt-graphics-video-item-video-player's Issues

How to implement a shape selection panel for rendering in PyQt5?

I'm designing graphic editor. As a scene for drawing, I need to use exactly QGraphicsScene. I implemented adding rectangles and ellipses to the scene with two buttons.

I need to implement dragging the faigures from the panel to the canvas, approximately as in the picture:

HDbv49RvRDI

What widgets or buttons can I use for this custom panel? Maybe there is an information an example with the implementation of a similar panel?

The program code with the implementation of adding shapes and the interface image:
`from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys

window class

class Window(QMainWindow):
def init(self):
super().init()

    wid = QWidget()
    self.setCentralWidget(wid)

    # setting title
    self.setWindowTitle("Paint with PyQt5")

    # setting geometry to main window
    self.setGeometry(100, 100, 800, 600)


    # Defining a scene rect of 400x200, with it's origin at 0,0.
    # If we don't set this on creation, we can set it later with .setSceneRect
    self.scene = QGraphicsScene(0, 0, 400, 200)

    # Set all items as moveable and selectable.
    for item in self.scene.items():
        item.setFlag(QGraphicsItem.ItemIsMovable)
        item.setFlag(QGraphicsItem.ItemIsSelectable)

    # Define our layout.
    vbox = QVBoxLayout()

    up = QPushButton("Rect")
    up.clicked.connect(self.add_rect)
    vbox.addWidget(up)

    down = QPushButton("Elips")
    down.clicked.connect(self.add_elips)
    vbox.addWidget(down)

    view = QGraphicsView(self.scene)
    view.setRenderHint(QPainter.Antialiasing)

    hbox = QHBoxLayout(self)
    hbox.addLayout(vbox)
    hbox.addWidget(view)

    wid.setLayout(hbox)

def add_rect(self):
    rect = QGraphicsRectItem(0, 0, 200, 50)
    rect.setPos(50, 20)
    rect.setFlag(QGraphicsItem.ItemIsMovable)
    rect.setFlag(QGraphicsItem.ItemIsSelectable)
    self.scene.addItem(rect)

def add_elips(self):
    ellipse = QGraphicsEllipseItem(0, 0, 100, 100)
    ellipse.setPos(75, 30)
    ellipse.setFlag(QGraphicsItem.ItemIsMovable)
    ellipse.setFlag(QGraphicsItem.ItemIsSelectable)
    self.scene.addItem(ellipse)

create pyqt5 app

App = QApplication(sys.argv)

create the instance of our Window

window = Window()

showing the window

window.show()

start the app

sys.exit(App.exec())`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.