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

📄 video.java

📁 这是一个用jsp+Oracle开发的联系人客户关系管理系统!
💻 JAVA
字号:
package com.test;

import java.applet.*;
import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.awt.event.*;
import java.io.*;
import javax.media.*;

public class video extends JApplet implements ControllerListener,Runnable,ItemListener
{
	Player player = null;
	String str = null;
	Thread thread = null;
	Choice choice;
	boolean flag = false;
	Component visualComponent = null;
	String mediaFile = null;
	URL mediaurl = null;
	Component controlComponent = null;
	Component porgressBar = null;
	JFrame myframe;

	public void init()
	{
		Container con = getContentPane();
		choice = new Choice();
		choice.add("movie01.MPG");
		choice.add("movie02.MPG");
		choice.add("movie03.MPG");
		choice.addItemListener(this);
		myframe = new JFrame("视频系统");
		myframe.setBackground(Color.blue);
		con.setBackground(Color.yellow);
		myframe.setSize(300,400);
		myframe.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				player.stop();
				player.deallocate();
				System.exit(0);}
		});
		myframe.setVisible(false);
		con.add(choice);
	}

	public void start()
	{
		if(flag)
		{
			thread.start();
			flag = false;
		}
	}

	public void stop()
	{
		if(player!=null)
		{
			player.stop();
		}
	}

	public void destroy()
	{
		player.close();
	}

	public synchronized void controllerUpdate(ControllerEvent event)
	{
		//myevent = event;
		if(event instanceof RealizeCompleteEvent)
		{
			if((visualComponent=player.getControlPanelComponent())!=null)
			{
				myframe.add("Center",visualComponent);
				if((controlComponent=player.getControlpanelComponent())!=null)
				{
					if(visualComponent!=null)
					{
						myframe.add("South",controlComponent);
					}
					else
					{
						myframe.add("center",controlComponent);
						myframe.validate();
						myframe.pack();
					}
				}
			}
		}
		else if(event instanceof PrefetchCompleteEvent)
		{
			player.start();
		}
	}

	public void itemStateChanged(ItemEvent e)
	{
		if(e.getItemSelectable==choice)
		{
			thread = null;
			this.stop();
			str = choice.getSelectedItem();
			myframe.removeAll();
			player = null;
			myframe.setVisible(true);
			thread = new Thread(this);
			flag = true;
			this.start();
		}
	}

	public void run()
	{
		try
		{
			mediaur1 = new URL(getDocumentBase(),"str");
			player = Manager.createPlayer(mediaurl);
			player.getDuration();
			if(player!=null)
			{
				player.addControllerListener(this);
			}
			else
			{
				System.out.println("Failed to create player for "+mediaurl);
			}
		}
		catch(MalformedURLException e1)
		{
			System.out.println("URL for "+str+" is invalid");
		}
		catch(IOException e2)
		{
			System.out.println("URL for "+str+" is invalid");
		}
		catch(NoPlayerException e3)
		{
			System.out.println("can't find a player for "+str);
		}

		if(player!=null)
		{
			player.prefetch();
		}
	}
};

⌨️ 快捷键说明

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