Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Antigravity A1: drone futuristico per riprese a 360° in 8K con qualche lacuna da colmare
Antigravity A1: drone futuristico per riprese a 360° in 8K con qualche lacuna da colmare
Abbiamo messo alla prova il drone Antigravity A1 capace di riprese in 8K a 360° che permette un reframe in post-produzione ad eliche ferme. Il concetto è molto valido, permette al pilota di concentrarsi sul volo e le manovre in tutta sicurezza e decidere con tutta tranquillità come gestire le riprese. La qualità dei video, tuttavia, ha bisogno di uno step in più per essere competitiva
Sony Alpha 7 V, anteprima e novità della nuova 30fps, che tende la mano anche ai creator
Sony Alpha 7 V, anteprima e novità della nuova 30fps, che tende la mano anche ai creator
Dopo oltre 4 anni si rinnova la serie Sony Alpha 7 con la quinta generazione, che porta in dote veramente tante novità a partire dai 30fps e dal nuovo sensore partially stacked da 33Mpixel. L'abbiamo provata per un breve periodo, ecco come è andata dopo averla messa alle strette.
realme GT 8 Pro Dream Edition: prestazioni da flagship e anima racing da F1
realme GT 8 Pro Dream Edition: prestazioni da flagship e anima racing da F1
realme e Aston Martin Aramco F1 Team si sono (ri)unite dando alla vita un flagship con chip Snapdragon 8 Elite Gen 5 e design esclusivo ispirato alle monoposto di Formula 1. La Dream Edition introduce la nuova colorazione Lime Essence abbinata al tradizionale Aston Martin Racing Green, decorazioni intercambiabili personalizzate e una confezione a tema F1, intorno a uno smartphone dall'ottima dotazione tecnica con batteria da 7000mAh ricaricabile a 120W e isola fotografica intercambiabile
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 21-02-2005, 17:23   #1
ally
Bannato
 
L'Avatar di ally
 
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
[Java]...actionlistner...

...non riesco ad implementare crrettamente gli action listner nel simpleplayer applet...dove sbaglio?...

package it.video;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.MenuShortcut;
import java.awt.Panel;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.media.CachingControl;
import javax.media.CachingControlEvent;
import javax.media.Controller;
import javax.media.ControllerClosedEvent;
import javax.media.ControllerErrorEvent;
import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.EndOfMediaEvent;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.RealizeCompleteEvent;
import javax.media.Time;

//import com.sun.media.util.JMFSecurity;

/**
* This is a Java Applet that demonstrates how to create a simple
* media player with a media event listener. It will play the
* media clip right away and continuously loop.
*
* <!-- Sample HTML
* <applet code=SimplePlayerApplet width=320 height=300>
* <param name=file value="sun.avi">
* </applet>
* -->
*/
public class SimplePlayerApplet extends Applet implements ControllerListener {

// media Player
Player player = null;
// component in which video is playing
Component visualComponent = null;
// controls gain, position, start, stop
Component controlComponent = null;
// displays progress during download
Component progressBar = null;
boolean firstTime = true;
long CachingSize = 0L;
Panel panel = null;
int controlPanelHeight = 0;
int videoWidth = 0;
int videoHeight = 0;

private MenuItem menuFullScreen;
private MenuItem menuOriginalSize;
private MenuItem menuStart;
private MenuItem menuStop;
private MenuItem menuPause;
private MenuItem menuClose;
private MenuItem menuExit;
private MenuItem menuOpen;

/**
* Read the applet file parameter and create the media
* player.
*/

MenuBar menu;
Menu menuView;
MenuShortcut shortcut;
MenuItem itemMenu;



public void init() {
//$ System.out.println("Applet.init() is called");
setLayout(null);
setBackground(Color.BLACK);
panel = new Panel();
panel.setLayout( null );
add(panel);
panel.setBounds(0, 0, 320, 240);

// input file name from html param
String mediaFile = null;
// URL for our media file
MediaLocator mrl = null;
URL url = null;

// Get the media filename info.
// The applet tag should contain the path to the
// source media file, relative to the html page.

if ((mediaFile = getParameter("FILE")) == null)
Fatal("Invalid media file parameter");

try {
url = new URL(getDocumentBase(), mediaFile);
mediaFile = url.toExternalForm();
} catch (MalformedURLException mue) {
}

try {
// Create a media locator from the file name
if ((mrl = new MediaLocator(mediaFile)) == null)
Fatal("Can't build URL for " + mediaFile);

/*
try {
JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager,
JMFSecurity.writePropArgs);
JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager,
JMFSecurity.readPropArgs);
JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager,
JMFSecurity.connectArgs);
} catch (Exception e) {}
*/

// Create an instance of a player for this media
try {
player = Manager.createPlayer(mrl);
} catch (NoPlayerException e) {
System.out.println(e);
Fatal("Could not create player for " + mrl);
}

// Add ourselves as a listener for a player's events
player.addControllerListener(this);

} catch (MalformedURLException e) {
Fatal("Invalid media file URL!");
} catch (IOException e) {
Fatal("IO exception creating player for " + mrl);
}

// This applet assumes that its start() calls
// player.start(). This causes the player to become
// realized. Once realized, the applet will get
// the visual and control panel components and add
// them to the Applet. These components are not added
// during init() because they are long operations that
// would make us appear unresposive to the user.
}

/**
* Start media file playback. This function is called the
* first time that the Applet runs and every
* time the user re-enters the page.
*/

public void start() {
//$ System.out.println("Applet.start() is called");
// Call start() to prefetch and start the player.
if (player != null)
player.start();
}

/**
* Stop media file playback and release resource before
* leaving the page.
*/
public void stop() {
//$ System.out.println("Applet.stop() is called");
if (player != null) {
player.stop();
player.deallocate();
}
}

public void destroy() {
//$ System.out.println("Applet.destroy() is called");
player.close();
}


/**
* This controllerUpdate function must be defined in order to
* implement a ControllerListener interface. This
* function will be called whenever there is a media event
*/
public synchronized void controllerUpdate(ControllerEvent event) {
// If we're getting messages from a dead player,
// just leave
if (player == null)
return;

// When the player is Realized, get the visual
// and control components and add them to the Applet
if (event instanceof RealizeCompleteEvent) {
if (progressBar != null) {
panel.remove(progressBar);
progressBar = null;
}

int width = 320;
int height = 0;
if (controlComponent == null)
if (( controlComponent =
player.getControlPanelComponent()) != null) {

controlPanelHeight = controlComponent.getPreferredSize().height;
panel.add(controlComponent);
height += controlPanelHeight;
}
if (visualComponent == null)
if (( visualComponent =
player.getVisualComponent())!= null) {
panel.add(visualComponent);
Dimension videoSize = visualComponent.getPreferredSize();
videoWidth = videoSize.width;
videoHeight = videoSize.height;
width = videoWidth;
height += videoHeight;
visualComponent.setBounds(0, 0, videoWidth, videoHeight);
}

panel.setBounds(0, 0, width, height);
if (controlComponent != null) {
controlComponent.setBounds(0, videoHeight,
width, controlPanelHeight);
controlComponent.invalidate();
}

} else if (event instanceof CachingControlEvent) {
if (player.getState() > Controller.Realizing)
return;
// Put a progress bar up when downloading starts,
// take it down when downloading ends.
CachingControlEvent e = (CachingControlEvent) event;
CachingControl cc = e.getCachingControl();

// Add the bar if not already there ...
if (progressBar == null) {
if ((progressBar = cc.getControlComponent()) != null) {
panel.add(progressBar);
panel.setSize(progressBar.getPreferredSize());
validate();
}
}
} else if (event instanceof EndOfMediaEvent) {
// We've reached the end of the media; rewind and
// start over
player.setMediaTime(new Time(0));
player.start();
} else if (event instanceof ControllerErrorEvent) {
// Tell TypicalPlayerApplet.start() to call it a day
player = null;
Fatal(((ControllerErrorEvent)event).getMessage());
} else if (event instanceof ControllerClosedEvent) {
panel.removeAll();
}
}


void Fatal (String s) {
// Applications will make various choices about what
// to do here. We print a message
System.err.println("FATAL ERROR: " + s);
throw new Error(s); // Invoke the uncaught exception
// handler System.exit() is another
// choice.

}

/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
*/
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub

int key = e.getKeyCode(); // keyboard code for the key that was pressed

if (key == KeyEvent.VK_LEFT) {
player.stop();
}
else if (key == KeyEvent.VK_RIGHT) {
player.start();
}

}

/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
*/
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub

int key = e.getKeyCode(); // keyboard code for the key that was pressed

if (key == KeyEvent.VK_P) {
player.stop();
}
else if (key == KeyEvent.VK_S) {
player.start();
}

}

/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
*/
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub

}

}


/*
<applet code=SimplePlayerApplet.class width=640 height=510>
<param name=file value="file:/usr/local/media/playme.mpg">
</applet>
*/

...in grassetto la parte in questione...
...grazie...
ally è offline   Rispondi citando il messaggio o parte di esso
Old 21-02-2005, 18:31   #2
ally
Bannato
 
L'Avatar di ally
 
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
...nessuno puo' aiutarmi ad inserire controlli da tastiera?...
ally è offline   Rispondi citando il messaggio o parte di esso
Old 22-02-2005, 15:30   #3
ally
Bannato
 
L'Avatar di ally
 
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
..risolto...il key event va implementato nell'applet e inserito come proprietà di un oggetto...
ally è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Antigravity A1: drone futuristico per riprese a 360° in 8K con qualche lacuna da colmare Antigravity A1: drone futuristico per riprese a ...
Sony Alpha 7 V, anteprima e novità della nuova 30fps, che tende la mano anche ai creator Sony Alpha 7 V, anteprima e novità della ...
realme GT 8 Pro Dream Edition: prestazioni da flagship e anima racing da F1 realme GT 8 Pro Dream Edition: prestazioni da fl...
OVHcloud Summit 2025: le novità del cloud europeo tra sovranità, IA e quantum OVHcloud Summit 2025: le novità del cloud...
Un mostro da MSI: QD-OLED WQHD a 500 Hz con AI Care e DisplayPort 2.1a Un mostro da MSI: QD-OLED WQHD a 500 Hz con AI C...
Axiom Space ha completato un importante ...
Gli aeroplani Airbus utilizzeranno i sat...
Una nuova immagine della cometa interste...
'La soluzione a un problema che non esis...
Radeon RX 9000 sì, Ryzen 9000 no:...
Amazon versa 180 milioni al Fisco e canc...
Meta, il Board di Supervisione guarda o...
DJI rivoluziona le consegne aeree: il nu...
Fibercop e Microsoft Italia uniscono per...
App Store Award 2025: scarica le 17 app ...
NVIDIA fa marcia indietro, il supporto P...
Addio definitivo alla GeForce GTX 1080: ...
Numeri record per gli iPhone 17: Apple s...
L'Italia del 2025 raccontata da Google: ...
Piaggio lancia Porter NPE, il pick-up el...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 22:02.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v