⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 panelmediatargetformat.java

📁 里面是关于jmf编程的例子,希望能给初学者带来一些帮助
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * @(#)PanelMediaTargetFormat.java	1.4 00/04/13 * * Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */package jmapps.export;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.media.*;import javax.media.control.*;import javax.media.format.*;import javax.media.protocol.*;//import javax.media.datasink.*;import com.sun.media.util.JMFI18N;import com.sun.media.ui.TabControl;import com.sun.media.ui.AudioFormatChooser;import com.sun.media.ui.VideoFormatChooser;import jmapps.ui.*;public class PanelMediaTargetFormat extends JMPanel implements ActionListener, ItemListener {    private Processor               processor = null;    private String                  strTargetType = PanelMediaTargetType.TYPE_OTHER;    private ContentDescriptor       arrContentDescriptors [] = null;    private Hashtable               hashtableContentDescriptors = null;    private TrackControl            arrTrackControls [] = null;    private String                  arrAllowContentType [] = null;    private JMPanel         panelContent;    private Choice          comboContentType;    private TabControl      tabControl;    private Vector          vectorPanelsAudio;    private Vector          vectorPanelsVideo;    private Vector          vectorTracksAudio;    private Vector          vectorTracksVideo;    private Image           imageAudioEn = null;    private Image           imageAudioDis = null;    private Image           imageVideoEn = null;    private Image           imageVideoDis = null;    public PanelMediaTargetFormat () {    	super ();    	try {    	    init ();    	}    	catch ( Exception exception ) {    	    exception.printStackTrace ();    	}    }    public void setAllowContentType ( String arrAllowContentType[] ) {        this.arrAllowContentType = arrAllowContentType;    }    private void init () throws Exception {    	Panel	   panelDescription;//        Toolkit    toolkit;    	this.setLayout ( new BorderLayout(6,6) );    	panelDescription = new Panel ( new GridLayout(0,1) );    	this.add ( panelDescription, BorderLayout.NORTH );    	panelDescription.add ( new Label(JMFI18N.getResource("jmstudio.export.format.label1")) );    	panelDescription.add ( new Label(JMFI18N.getResource("jmstudio.export.format.label2")) );        panelContent = new JMPanel ( new BorderLayout(6,6) );        panelContent.setEmptyBorder ( 6, 6, 6, 6 );        this.add ( panelContent, BorderLayout.CENTER );        imageAudioEn = ImageArea.loadImage ( "audio.gif", this, true );        imageAudioDis = ImageArea.loadImage ( "audio-disabled.gif", this, true );        imageVideoEn = ImageArea.loadImage ( "video.gif", this, true );        imageVideoDis = ImageArea.loadImage ( "video-disabled.gif", this, true );    }    public void setProcessor ( Processor processor, String strContType, String strTargetType ) {        this.processor = processor;        this.strTargetType = strTargetType;        arrContentDescriptors = processor.getSupportedContentDescriptors ();        arrTrackControls = processor.getTrackControls ();        panelContent.removeAll ();        buildPage ();        if ( strTargetType.equals(PanelMediaTargetType.TYPE_NETWORK) )            strContType = (new ContentDescriptor(ContentDescriptor.RAW_RTP)).toString ();        if ( strTargetType.equals(PanelMediaTargetType.TYPE_SCREEN) )            strContType = (new ContentDescriptor(ContentDescriptor.RAW)).toString ();        if ( strContType != null )            comboContentType.select ( strContType );        changeContentType ();    }    public void updateProcessorFormat () {        int                 i;        int                 nCount;        VideoFormatChooser  panelVideo;        AudioFormatChooser  panelAudio;        TrackControl        trackControl;        Format              format;        nCount = vectorPanelsVideo.size ();        for ( i = 0;  i < nCount;  i++ ) {            panelVideo = (VideoFormatChooser) vectorPanelsVideo.elementAt ( i );            trackControl = (TrackControl) vectorTracksVideo.elementAt ( i );            if ( panelVideo.isTrackEnabled() == false ) {                trackControl.setEnabled ( false );                continue;            }            format = panelVideo.getFormat ();            if ( format == null ) {                MessageDialog.createErrorDialog ( this.getFrame(), "Internal error. Unable to match choosen video format. Track will be disabled." );                trackControl.setEnabled ( false );            }            else {                trackControl.setEnabled ( true );                trackControl.setFormat ( format );            }        }        nCount = vectorPanelsAudio.size ();        for ( i = 0;  i < nCount;  i++ ) {            panelAudio = (AudioFormatChooser) vectorPanelsAudio.elementAt ( i );            trackControl = (TrackControl) vectorTracksAudio.elementAt ( i );            if ( panelAudio.isTrackEnabled() == false ) {                trackControl.setEnabled ( false );                continue;            }            format = panelAudio.getFormat ();            if ( format == null ) {                MessageDialog.createErrorDialog ( this.getFrame(), "Internal error. Unable to match choosen audio format. Track will be disabled." );                trackControl.setEnabled ( false );            }            else {                trackControl.setEnabled ( true );                trackControl.setFormat ( format );            }        }    }    public boolean[] getEnabledVideoTracks () {        int                 i;        int                 nCount;        VideoFormatChooser  panelVideo;        boolean             arrResult [];        nCount = vectorPanelsVideo.size ();        arrResult = new boolean [ nCount ];        for ( i = 0;  i < nCount;  i++ ) {            panelVideo = (VideoFormatChooser) vectorPanelsVideo.elementAt ( i );            arrResult[i] = panelVideo.isTrackEnabled ();        }        return ( arrResult );    }    public boolean[] getEnabledAudioTracks () {        int                 i;        int                 nCount;        AudioFormatChooser  panelAudio;        boolean             arrResult [];        nCount = vectorPanelsAudio.size ();        arrResult = new boolean [ nCount ];        for ( i = 0;  i < nCount;  i++ ) {            panelAudio = (AudioFormatChooser) vectorPanelsAudio.elementAt ( i );            arrResult[i] = panelAudio.isTrackEnabled ();        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -