Note that there are some explanatory texts on larger screens.

plurals
  1. POwhen i choose a video file through JMF, i hear only audio, but video does not work
    primarykey
    data
    text
    <p>`this is the first class<br> the jmf video player is put into a panel</p> <pre><code>import java.awt.BorderLayout; import java.awt.Component; import java.io.IOException; import java.net.URL; import javax.media.CannotRealizeException; import javax.media.Manager; import javax.media.NoPlayerException; import javax.media.Player; import javax.swing.JPanel; public class MediaPanel extends JPanel { public MediaPanel(URL mediaURL) { setLayout(new BorderLayout()); Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true); try { Player mediaPlayer = Manager.createRealizedPlayer(mediaURL); Component video = mediaPlayer.getVisualComponent(); Component controls = mediaPlayer.getControlPanelComponent(); if (video != null) { add(video, BorderLayout.CENTER); } if (controls != null) { add(controls, BorderLayout.SOUTH); } mediaPlayer.start(); } catch (NoPlayerException noPlayerException) { System.err.println("No media Player Found"); } catch (CannotRealizeException cannotRealizeException) { System.err.println("Could not media Player"); } catch (IOException ioException) { System.err.println("Err reading from the source"); } } } </code></pre> <p>this is the second class that calls the video player in the JPanel to the frame</p> <pre><code>import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.swing.JFileChooser; import javax.swing.JFrame; public class MediaTest { public static void main(String[] args) { JFileChooser filechooser = new JFileChooser(); int result = filechooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION) { URL mediaURL = null; try { mediaURL = filechooser.getSelectedFile().toURI().toURL(); } catch (MalformedURLException malformedURLException) { System.err.println("Could not create URL for the file"); } if (mediaURL != null) { JFrame mediaTest = new JFrame("Media Tester"); mediaTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MediaPanel mediaPanel = new MediaPanel(mediaURL); mediaTest.add(mediaPanel); mediaTest.setSize(300, 300); mediaTest.setVisible(true); } } } } </code></pre> <p>the problem is when I choose a video file, I can only hear the audio, but video does not display/show<br> please help </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload