10
Computer Science [3] Computer Science [3] Java Programming II - Java Programming II - Laboratory Course Laboratory Course Lab 7: Lab 7: Multimedia: Applets and Applications Multimedia: Applets and Applications Faculty of Engineering & IT Software Engineering Department WWW.PALINFONET.COM Eng.Omar Al-Nahal

Computer Science [3] Java Programming II - Laboratory Course

Embed Size (px)

DESCRIPTION

Faculty of Engineering & IT Software Engineering Department. Computer Science [3] Java Programming II - Laboratory Course. Lab 7: Multimedia: Applets and Applications. WWW. PALINFONET .COM. Eng . Omar Al-Nahal. Multimedia: Applets and Applications. - PowerPoint PPT Presentation

Citation preview

Page 1: Computer Science [3]  Java Programming II -  Laboratory Course

Computer Science [3] Computer Science [3] Java Programming II - Java Programming II - Laboratory Laboratory

Course Course

Lab 7:Lab 7:

Multimedia: Applets and ApplicationsMultimedia: Applets and Applications

Faculty of Engineering & ITSoftware Engineering Department

WWW.PALINFONET.COMWWW.PALINFONET.COM

Eng.Omar Al-Nahal

Eng.Omar Al-Nahal

Page 2: Computer Science [3]  Java Programming II -  Laboratory Course

Loading, Displaying and Scaling Images Loading, Displaying and Scaling Images Animating a Series of Images Animating a Series of Images Loading and Playing Audio Clips Loading and Playing Audio Clips Playing Video and Other Media with Java Media FrameworkPlaying Video and Other Media with Java Media Framework

Multimedia: Applets and ApplicationsMultimedia: Applets and Applications

Page 3: Computer Science [3]  Java Programming II -  Laboratory Course

Loading, Displaying and Scaling Loading, Displaying and Scaling ImagesImages

Classes Classes ImageImage and and ImageIconImageIcon – used to load and display images – used to load and display images Displaying imagesDisplaying images

• GraphicsGraphics method method drawImagedrawImage – used to draw image referenced by – used to draw image referenced by ImageImage object (can be scaled)object (can be scaled)

• ImageIconImageIcon method method paintIconpaintIcon can be used to draw image referenced by can be used to draw image referenced by ImageIconImageIcon object object

Loading imagesLoading images• AppletApplet method method getImagegetImage loads an loads an ImageImage into an applet into an applet• Applet method Applet method getDocumentBasegetDocumentBase returns location of applet’s HTML file on returns location of applet’s HTML file on

InternetInternet• ImageObserverImageObservers receive notifications as s receive notifications as ImageImage is loaded and update image on is loaded and update image on

screen if it was not complete when displayedscreen if it was not complete when displayed Java supports several image formats, including GIF, JPEG and PNGJava supports several image formats, including GIF, JPEG and PNG

See Img-Example

Page 4: Computer Science [3]  Java Programming II -  Laboratory Course

Animating a Series of ImagesAnimating a Series of Images

Animation can be created by displaying a sequence of similar imagesAnimation can be created by displaying a sequence of similar images TimerTimer object can be used to specify when each image is displayed object can be used to specify when each image is displayed TimerTimer objects generate objects generate ActionEventActionEvents at fixed intervalss at fixed intervals

• Method Method startstart – – TimerTimer should start generating events should start generating events• Method Method stopstop – – TimerTimer should stop generating events should stop generating events• Method Method restartrestart – – TimerTimer should start generating events again should start generating events again

ComponentComponent method method getPreferredSizegetPreferredSize determines the preferred determines the preferred width and height of a componentwidth and height of a component

ComponentComponent method method getMinimumSizegetMinimumSize determines the minimum determines the minimum width and height of a componentwidth and height of a component

See Images-Example

Page 5: Computer Science [3]  Java Programming II -  Laboratory Course

Loading and Playing Audio ClipsLoading and Playing Audio Clips

Java programs can play and manipulate audio clipsJava programs can play and manipulate audio clips Playing sounds in an appletPlaying sounds in an applet

• AppletApplet’s ’s playplay method – loads sound and plays once method – loads sound and plays once

• AudioClipAudioClip’s ’s playplay, , looploop and and stopstop methods methods

• Additional capabilities provided by JMF and Java Sound APIsAdditional capabilities provided by JMF and Java Sound APIs Loading sounds in an appletLoading sounds in an applet

• AppletApplet method method getAudioClipgetAudioClip – retrieves sound, returns reference to – retrieves sound, returns reference to an an AudioClipAudioClip

• AppletApplet’s ’s playplay method loads sound method loads sound Supported file formats include Sun Audio file format, Windows Wave Supported file formats include Sun Audio file format, Windows Wave

file format, MIDI file formatfile format, MIDI file format

Page 6: Computer Science [3]  Java Programming II -  Laboratory Course

Loading and Playing Audio ClipsLoading and Playing Audio Clips

See Playing Audio Example

Page 7: Computer Science [3]  Java Programming II -  Laboratory Course

Playing Video and Other Media with Java Media Playing Video and Other Media with Java Media FrameworkFramework

A simple video can concisely and effectively convey a great A simple video can concisely and effectively convey a great deal of informationdeal of information

JMF API enables Java programmers to play, edit, stream JMF API enables Java programmers to play, edit, stream and capture popular media typesand capture popular media types

Supported file types include Microsoft Audio/Video Supported file types include Microsoft Audio/Video Interleave, Macromedia Flash2 movies, MPEG-1 videos Interleave, Macromedia Flash2 movies, MPEG-1 videos and QuickTime moviesand QuickTime movies

Page 8: Computer Science [3]  Java Programming II -  Laboratory Course

Creating a Simple Media PlayerCreating a Simple Media Player

Interface Interface PlayerPlayer used to play video used to play video Class Class ManagerManager declares utility methods for accessing system resources declares utility methods for accessing system resources

to play and manipulate mediato play and manipulate media Manager method Manager method createRealizedPlayercreateRealizedPlayer obtains a obtains a PlayerPlayer for a for a

specified media clipspecified media clip Loading and playing videoLoading and playing video

• PlayerPlayer method method getVisualComponentgetVisualComponent gets component that displays gets component that displays visual aspect of media filevisual aspect of media file

• PlayerPlayer method method getControlPanelComponentgetControlPanelComponent gets component that gets component that provides playback and media controlsprovides playback and media controls

• PlayerPlayer method start begins playing media file method start begins playing media file

Page 9: Computer Science [3]  Java Programming II -  Laboratory Course

Creating a Simple Media PlayerCreating a Simple Media Player

See Media Player -Example

Page 10: Computer Science [3]  Java Programming II -  Laboratory Course

Internet and World Wide Web Internet and World Wide Web ResourcesResources

Internet and web resources for Java Media FrameworkInternet and web resources for Java Media Framework

http://java.sun.com/products/java-media/jmf/http://java.sun.com/products/java-media/jmf/

– Download and documentation for JMFDownload and documentation for JMFhttp://java.sun.com/products/java-media/ jmf/forDevelopers/http://java.sun.com/products/java-media/ jmf/forDevelopers/

– Site for Site for javax.mediajavax.media API descriptions API descriptions

Downloadable image, audio, and video galleries Downloadable image, audio, and video galleries • Test your multimedia programsTest your multimedia programshttp://www.nasa.gov/gallery/index.htmlhttp://www.nasa.gov/gallery/index.htmlhttp://sunsite.sut.ac.jp/multimed/ http://sunsite.sut.ac.jp/multimed/