Play movie with JMF
Hey,
I just started out with JMF (I wanted to play a movie with java).
I got this code:
import java.applet.*;
import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.util.*;
import javax.media.*;
* Demonstrate simple code to play a movie with Java Media Framework.
* @author Ian F. Darwin, http://www.darwinsys.com/
* @version $Id: JMFPlayer.java,v 1.9 2004/02/09 03:21:20 ian Exp $
public class NewJApplet extends JPanel implements ControllerListener {
/** The player object */
Player thePlayer = null;
/** The parent Frame we are in. */
JFrame parentFrame = null;
/** Our contentpane */
Container cp;
/** The visual component (if any) */
Component visualComponent = null;
/** The default control component (if any) */
Component controlComponent = null;
/** The name of this instance's media file. */
String mediaName;
/** The URL representing this media file. */
URL theURL;
/** Construct the player object and the GUI. */
public NewJApplet(JFrame pf, String media) {
parentFrame = pf;
mediaName = media;
// cp = getContentPane();
cp = this;
cp.setLayout(new BorderLayout());
try {
theURL = new URL(getClass().getResource("."), mediaName);
thePlayer = Manager.createPlayer(theURL);
thePlayer.addControllerListener(this);
} catch (MalformedURLException e) {
System.err.println("JMF URL creation error: " + e);
} catch (Exception e) {
System.err.println("JMF Player creation error: " + e);
return;
System.out.println("theURL = " + theURL);
// Start the player: this will notify our ControllerListener.
thePlayer.start(); // start playing
/** Called to stop the audio, as from a Stop button or menuitem */
public void stop() {
if (thePlayer == null) {
return;
thePlayer.stop(); // stop playing!
thePlayer.deallocate(); // free system resources
/** Called when we are really finished (as from an Exit button). */
public void destroy() {
if (thePlayer == null) {
return;
thePlayer.close();
/** Called by JMF when the Player has something to tell us about. */
public synchronized void controllerUpdate(ControllerEvent event) {
// System.out.println("controllerUpdate(" + event + ")");
if (event instanceof RealizeCompleteEvent) {
if ((visualComponent = thePlayer.getVisualComponent()) != null) {
cp.add(BorderLayout.CENTER, visualComponent);
if ((controlComponent = thePlayer.getControlPanelComponent()) != null) {
cp.add(BorderLayout.SOUTH, controlComponent);
// re-size the main window
if (parentFrame != null) {
parentFrame.pack();
parentFrame.setTitle(mediaName);
public static void main(String[] argv) {
JFrame f = new JFrame("JMF Player Demo");
Container frameCP = f.getContentPane();
NewJApplet p = new NewJApplet(f,
argv.length == 0 ? "file:/C:/Users/Patrick Kos/Pictures/BAA.avi"
: argv[0]);
frameCP.add(BorderLayout.CENTER, p);
f.setSize(200, 200);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}but I always get a unable to handle format exception, expect with mp3 files.
But i"ve looked up the supported formats and its says its supported so??
i get this error
Unable to handle format: XVID, 320x240, FrameRate=29.9, Length=230400 0 extra bytes
Unable to handle format: unknown, 22050.0 Hz, 0-bit, Stereo, Unsigned, 8000.0 frame rate, FrameSize=9216 bits
Failed to realize: com.sun.media.PlaybackEngine@7259da
Error: Unable to realize com.sun.media.PlaybackEngine@7259da
Exception in thread "main" javax.media.CannotRealizeException
at javax.media.Manager.blockingCall(Manager.java:2005)
at javax.media.Manager.createRealizedPlayer(Manager.java:580)
at projectnemo.NewJApplet.main(NewJApplet.java:102)
Similar Messages
-
Record / copy playing movie with JMF
Hi
I am trying to copy a videofile which I am playing in JMF. It's easy as long as I want the whole video, but how can I cut out a part of the file? Any solution or example?
Regards
Saqiwhich type of file formats you are using tell me
-
What application will allow me to play movies with an external disc drive?
What application will allow me to play movies with an external disc drive? I recently purchased an external disc drive and when testing it discovered that it only played the audio of the DVD, not the video. Very frustrated.
Are you referrring to a commercial DVD movie, or a disk with digital movies, such as mpeg files?
-
Hello,
I would like to know how to make hinted movies with JMf, but no One seem to talk about this in forums...
Any idea ?Get binary distro and follow Manual Installation section of http://fobs.sourceforge.net/f4jmf_first.html
-
How to play movies with different ext like wmv and...
need to know how to play movies with various ext like wmv..mpeg..vlc on e7
If the phone's built-in video player does not handle those formats, your option are:
- find some other video player app that does, or
- convert the videos to a supported format
The E7 supported video formats are listed on, e.g., this page:
https://www.developer.nokia.com/Devices/Device_specifications/E7-00/
Hit "Expand all" and scroll down to "Video Playback Formats". -
Playing movies with locked screen (OS X, iOS)?
Is there a way to make OS X or iOS devices to play movies with the screen locked?
Like this (I first submitted the question in Vision because I also need to be able to have the movies play without video, AND with headphones as the standard "viewing screen" - currently this is not working neither for iPhone or iPad... of course there are a bit more audio narration options when using a full Mac instead)
iOS: movies and TV with audio only, with locked screen?Answered in http://discussions.apple.com/thread.jspa?messageID=12732692
-
HT3775 how to play movie with mp4
how to play movie with mp4
Sorry, but I for one do not understand what it is you're trying to accomplish. Can you please explain in more detail?
-
Play movie with subtitle..
i am using JMF player to play movies
i have downloaded some codecs (jffmpeg)
but one thing is missing
displaying subtitles
i been searching google but find nothing
There is something written all ready
or
should i start thinking how to do it my self.
i am thinking about using a glass pane to draw the subtitles
but i need and a subtitle parser (SRT,SUB files)
there is something written in java ?
or i need to do it by my self.
if all made by me?
i have question about subtitle timing
can i use JMF to throw some event when a
certain time in the movie is arrived
i don't want to check every second?
allot of questions
any help will be appreciated
thanks allot
shayIt's so xxxx complicated to play a movie with subtitels
since JMF was last updated at 2004.
i am giving a try to MPlayer.
may be when there is a new version of JMF
with no need of hacking things like:
searching for codecs all over the web
find one site that hack JMF to display text over JMF Player .(and i searched google)
find a responsible why to handle player timing (subtitle timing)
and more simple why to play a movie without catching alot of exceptions
till you lost your mind.
sorry .i rely give it a try.
thanks allot every one. -
Hey,
Im searching for a way to play a movie with java (without using JMF or javafx, these are media players only?),
I want to play a movie in my app. how do i do this?I don't know, but JMF is not as inflexible as you imagine it to be. Why not ask in the forum dedicated to JMF?
[http://forums.sun.com/forum.jspa?forumID=28] -
Error Playing Movie with htaccess
If I use .htaccess file to authenticate connections to my stock apache/10.4.11 web server, the iPhone will error out with "Error Playing Movie" when it tries to access the file. It does authenticate and show the contents of the directory. It will also view other document types, such as html files, without error. If I remove the .htaccess, it will play the movie.
I dont recall my previous iPod Touch exhibiting this behavior, however I no longer have it available for testing.
Packet capture on the shows:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>401 Authorization Required</TITLE>
</HEAD><BODY>
Authorization Required
This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.
<HR>
<ADDRESS>Apache/1.3.33 Server at lemonhead.local Port 80</ADDRESS>
</BODY></HTML>
Is this an iPhone/Safari problem, or apache problem? The site works fine using the Camino browser within OS X. Any ideas?
Message was edited by: Bain
Message was edited by: BainI can play that movie when I am connected via wi-fi -- it does not play for me via Edge (at least right where I am sitting :>).
This does happen a lot -- often a movie needs the bandwidth of wi-fi to play properly and if you are in a sketchy Edge territory you may have problems. Are you connected via wi-fi? Make sure it says that on your iPhone (you can see the wi-fi symbol right next to the AT&T on the top left of the iPhone display -- looks like little waves). If the video still doesn't play when you are connected via wi-fi let me know and we'll see what else we can try. -
Play sound with JMF on xletview
How to play a sound (such as midi) file with JMF?
now I test it on xletview,
Manager.createPlayer(new MediaLocator("file://D:/Project/Test/classes/0.mid"));
how can I use relative path instead of using absolute path?
thx for your helpHi Redduke
Althought your post is from July 2007 I will reply you ;)
I'm trying to plays video on JMF (on a MHP project), but I can't. Nevertheless I am capable to play audio from two different ways:
1. Via HSound: You create an HSound player, load the file on it and then plays it
2. Via JMFPlayer: Like before but with JMF
The restriction is that the sound would be in .mp1 o .mp2 format. I try with .mp2 and i can plays audio.
Regards ;) -
Apple TV Cannot Play Movies with iTunes Extras
For some reason, when I click on a movie in iTunes (downloaded from the iTunes Store), it plays the iTunes Extras by default, not the movie. I noticed the problem when I could not get my ATV2 to show these movies via Home Sharing. The affected movies do not even show up on my ATV2 via home sharing. Does anyone have any idea what is causing the iTunes Extra file to be the default playback file for a movie? Movies in my iTunes library that don't have iTunes Extras play just fine in iTunes and on my ATV2.
Go to your itunes library on computer and highlight the Movies category, try to find the movie - then right click and 'Show in Finder' (or Windows equivalent to view the actual movie files).
For each movie with extras you should have:
MovieName.m4v (main feature)
and
MovieName - iTunes Extras.ite (extras files)
You should actually see an entry for each in itunes grouped together.
AC -
Don't Send Error when playing movies with CL Entertaiment Cen
When I try to watch movies with the Creative Entertaiment Center (via remote) but I get the don't send error bellow. Music and photos have no issues, only movies give me errors. Any ideas?
http://img399.imageshack.us/my.php?image=eroareey5.jpg?
Message Edited by Theraphosa on 06-04-2008 08:6 AMWrite this piece of code in a Module inside the Screen 1000.
IF remarks IS INITIAL.
* Create obejct for custom container
CREATE OBJECT remarks_con
EXPORTING
container_name = 'REMARKS'.
* Create obejct for the TextEditor control
CREATE OBJECT remarks
EXPORTING
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length2
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
parent = remarks_con.
CALL METHOD remarks->set_toolbar_mode
EXPORTING
toolbar_mode = '0'.
CALL METHOD remarks->set_statusbar_mode
EXPORTING
statusbar_mode = '0'.
* call method mremarks->set_font_fixed
* exporting
* font_fixed = '0'.
ENDIF.
IF addnotes IS INITIAL.
* Create obejct for custom container
CREATE OBJECT addnotes_con
EXPORTING
container_name = 'ADDNOTES'.
* Create obejct for the TextEditor control
CREATE OBJECT addnotes
EXPORTING
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length2
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
parent = addnotes_con.
CALL METHOD addnotes->set_toolbar_mode
EXPORTING
toolbar_mode = '0'.
CALL METHOD addnotes->set_statusbar_mode
EXPORTING
statusbar_mode = '0'.
* call method mremarks->set_font_fixed
* exporting
* font_fixed = '0'.
ENDIF.
In the PBO module of the Screen 1000.
Hope That Helps
Anirban M. -
Playing movie with text button
I'm trying to get a movie to start once I click on a text button (play movie). So far I have this code in place and it is working. I just need to know the function necessary to start the movie to put in place of the comment I have below.
play_btn.addEventListener (MouseEvent.CLICK,playClick);
function playClick(e:MouseEvent)
//code to start movie
THANKS!If the movie that is supposed to play is the one containing the button, then you can just put play(); inside the function. But if it is some other movie, you'll need to target that movie by its instance name... mcName.play();
-
DVD player doesn't play movies with .avi extension
My friend recently gave me dvds that had movies burnt off the net. They're all files with .avi extensions. When i tried to open the file, it said i needed a higher version of quick time player, which i downloaded off the apple site.
After all this, i still can't play my dvd. What's happening here? The drive also makes these weird noises, like there's something seriously going wrong with the dvd. I tried playing it through dvd player on my mac book pro, but i couldn't open any file on it. It keeps sayin " NOT PERMITTED" . Funny part is, my friend could easily watch all these movies on his windows xp computer...
Please helppp !!!I think it is unforgivable a DVD player won't play DVD's that are not actually DVD's at all but data disks. I am still mad my DVD player will not paint my house.
Windows uses the one size fits all WM Player and it plays DVD and data disks or files etc.
Use Quicktime and Perian (free) to play those pesky files either from the DVD or from a drag and drop to the desktop first.
Message was edited by: A Train Car Full of Escaped Convicts
Maybe you are looking for
-
Firefox - Spry tabbed panel issue
Hi, need a little trouble shooting help here. This works fine in ie7 but not Firefox 2 or 3. The Spry Tabbed Panel just looks like an ordinary unordered list but it's still clickable. I've placed the script in the header and the css is imported in th
-
Contextual feature code samples
Here are some rather unusual examples of contextual features used to achieve some special effects. I hope they inspire interesting and creative uses. Here are three examples of interesting effects one can achieve by using contextual alternates in Ope
-
User-exit removed in the upgrade!!
Hi, we recently upgraded to ecc 6.0 previously there was a customer exit rmvkon00_003 in 4.6c but now in ecc 6.0 it has been removed and replace by a BADI How do I find and implement that BADI?
-
Publishing new site to existing URL
I am doing a complete face lift to my site and so creating a completely new muse file. My concern is that when I publish this new one in place of the old one, there will be old info stored in Business Catalyst which would mess up the site. Is this so
-
Help! iTunes deleted my library!!
Yesterday, I was trying to open iTunes, when it read the library and said that it was "damaged". It then proceeded to create a new blank library. This has happened before, and usually the libraries are not actually damaged, so what I usually did was