I wanto to play a mp4 video inside of my java application. The software is running fine on my main PC where a sound card is installed. But on another PC with no sound device at all, this is the content of the player.getError:
MediaException: PLAYBACK_HALTED : DirectSoundCreate: (NULL)
This is a part of the code:
import java.awt.BorderLayout;
import java.io.File;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Mixer.Info;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
Media m = new Media(file.toURI().toString());
MediaPlayer player = new MediaPlayer(m);
MediaView viewer = new MediaView(player);
player.setAutoPlay(true);
player.setCycleCount(MediaPlayer.INDEFINITE);
player.setOnError(()->Logging.getLogger().log("MediaPlayer setOnError: " + player.getError().toString(),Message.MESSAGE));
I can provide more code, if necessary. Once before I provided too much code and got bad comments about that.
My questions, how can I configure javaFX media player or one of it's components to run the video without a sound device. There must be something to configure. But I do not know.
Edit:
I was checking the versions of javafx on both PCs:
System.out.print(com.sun.javafx.runtime.VersionInfo.getRuntimeVersion());
8.0.311-b11 (Office PC where the code is working)
8.0.201-b08 (Shopfloor PC where the code is not working)
Edit:
I have installed a virtual sound card on the shopfloor PC. The error message disappeared. But no video is playing. No error message is showing. No exception is showing.
I need to get in contact with out MES supplier, because my java code on the shopfloor PC is running inside of a MES system.
(MES = Manufacturing Execution System)
Related
I'm following along the guide to setup Meteor Tabular v2.1.2 (guide). I have added the package and installed the theming packages. I'm using Meteor v2.8.0 and the project is a Blaze-based project.
In client/main.js, I set up the library as instructed.
import { $ } from 'meteor/jquery';
import dataTablesBootstrap from 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css';
import "../imports/ui/body";
dataTablesBootstrap(window, $);
Now when I go to the browser, there is this error:
Can anyone help me on this?
So after serious debugging , I discovered it is enough to just import the DataTable module as such after installing it with npm
import { $ } from 'meteor/jquery';
import 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css';
import "../imports/ui/body";
// You don't need the code previously here .
You can now setup you DataTable as such
$(element).DataTable(//Your config object)
My project folder as below:
C:\HHS\Actions<mysomeclass>.py
C:\HHS\Configuration<mysomesetting>.txt
C:\HHS\Data<mysomedata>.txt
C:\HHS\Form<mysomeclass>.py
C:\HHS\Testcases<mysometestcaseclass>.py
C:\HHS\Labels\OCR\Tmp<somefile>.png
C:\HHS\main.py
C:\HHS<somebatfile>.bat
After build exe file by command: C:\HHS>pyinstaller --paths=C:\HHS\Actions;C:\HHS\Form;C:\HHS\Testcase main.py
I copy all folder Actions , Configuration, Data, Form , Testcase, all file .bat to C:\HHS\dist\main
After that I run file main.exe in dist\main. It overcome the previous issue (How to release an application write by Python (which has structure folder) to user) but I met the other issue as below:
C:\HHS\dist\main>main.exe
Which testcase do you want to test
1. Image Capture
2. Reset Base
3. OCRTestcase
4. USBOEMCommand (remember turn off Vietnamese)
Please enter that number : 1
C:\HHS\dist\main> py C:\HHS\dist\main\Testcases\ImageCapture.py
Traceback (most recent call last):
File "C:\HHS\dist\main\Testcases\ImageCapture.py", line 9, in <module>
from Actions.Config import Config
ModuleNotFoundError: No module name 'Actions'
This is my ImageCapture.py
import os
import serial
import time
import sys
import os
import logging
from Actions.Config import Config
import Actions.Common as Common
from datetime import datetime
from Actions import DBv2
from Actions.parselog2 import ParseLog
I know maybe how I import module Actions is not correct (although it can run successful by Pycharm) but not work after build exe. I don't know how to fix it. Please help me. Thanks alot.
I'm still developing my project and I want to make a lot of changes to UI through HTML/CSS, I'm starting the Bokeh server programmatically and it looks like this:
from tornado.ioloop import IOLoop
from tornado.web import StaticFileHandler
from bokeh.server.server import Server
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from os.path import dirname, join
import sys
if not dirname(__file__) in sys.path: sys.path.append(dirname(__file__))
from models.ProjectDataLoading import modify_page1
from models.Empty import modify_page2
page1_app = Application(FunctionHandler(modify_page1))
page2_app = Application(FunctionHandler(modify_page2))
StaticFileHandler.reset()
io_loop = IOLoop.current()
server = Server(applications = {'/ProjectDataLoading': page1_app,
'/PrimaveraObjects': page2_app,
'/SpecializedReports': page2_app,
'/StatisticalReports': page2_app,
'/Predictions': page2_app},
extra_patterns=[(r'/static/css/(.*)', StaticFileHandler, {'path':join(dirname(__file__),"static","css")})],
io_loop = io_loop, port = 5006, static_hash_cache=False, debug=True, autoreload=True, compiled_template_cache=False, serve_traceback=True)
server.start()
server.show('/ProjectDataLoading')
io_loop.start()
I'm still working on page1 -> "ProjectDataLoading", and as you can see I'm trying to make the server to stop cashing the static files with the following codes:
StaticFileHandler.reset()
static_hash_cache=False
debug=True
of course, it's wrong, because it's related to tornado application, not Bokeh server, so, how can I do it Bokeh server?
Almost all the code to support dev mode, i.e. watching a list file files and auto-reloading, is in the application part of the Bokeh server, not in the library. So you would need to essentially reproduce the code here:
https://github.com/bokeh/bokeh/blob/8f9cf0a85ba51098da2d027150e900bfc073eeba/bokeh/command/subcommands/serve.py#L785-L816
I'm trying to send an image from my drive to telegram using the method sendPhoto but I can't. Which is the trick ?
I'm using Python 3.6.7 My code is as follows:
import sys
import telepot
import aiohttp
import asyncio
import os
import time
bot = telepot.Bot('55615????:AA????)
bot.getMe()
id=32????
bot.sendPhoto(chatId, str(open("th-623777.jpg", os.O_RDONLY)) )
I have installed qpython for android, the problem is that when I install a module with pip in the python console I can import it properly, but not when I try to import it to a script.
in console ... I type:
>>>import requests
>>>requests
<module 'requests' from '/data/data/com.hipipal.qpyplus/.../__init__.py>
but in a script saved in scripts' folder, when I execute:
import requests
r = requests.get("http://www.google.com")
print r.text.encode('utf-8')
I get this:
import requests
ImportError: no module named requests
Can anybody help with that?
Thank you!
Add import site.
This works on my tablet:
#-*-coding:utf8;-*-
#qpy:2
#qpy:console
import site
import requests
r = requests.get("http://www.google.com")
print r.text.encode('utf-8')