Media Components

Camera
ImagePicker
Player
Sound
VideoPlayer
Camera

Use a camera component to take a picture on the phone.

Camera is a non-visible component that takes a picture using the device's camera. After the picture is taken, the path to the file on the phone containing the picture is available as an argument to the AfterPicture event. The path can be used, for example, as the Picture property of an Image component.

Properties
none
Methods
TakePicture()
Opens the phone's camera to allow a picture to be taken.
Events
AfterPicture(Text image)
Called after the picture is taken. The text argument image is the path that can be used to locate the image on the phone.
ImagePicker

Use an image picker component to choose an image from your image gallery.

An image picker is a kind of button. When the user taps an image picker, the device's image gallery appears, and the user can choose an image. After the user picks an image, the property ImagePath is set to a text string that represents that image. You can then use that result, for example, to set the image of a button.

Properties
ImagePath
The image the user chose, represented as a text string that gives the location of the images.
Enabled
If true, image picker can be used.
Alignment
Left, center, or right.
BackgroundColor
Color for image picker background.
Enabled
If set, user can tap image picker to cause action.
FontBold
If set, image picker button text is displayed in bold.
FontItalic
If set, image picker button text is displayed in italics.
FontSize
Point size for image picker button text.
FontTypeface
Font family for image picker button text.
Height
image picker button height (y-size).
Width
image picker button width (x-size).
Image
Image to display on image picker button.
Text
Text to display on image picker button.
TextColor
Color for image picker button text.
Events
AfterPicking()
User selected an item from the image picker.
BeforePicking()
User has tapped the image picker but hasn't yet selected an item.
GotFocus()
Image picker became the focused component.
LostFocus()
Image picker is no longer the focused component.
Player

Use a player component to play an audio or video file, or to vibrate the phone.

Player is a non-visible component that plays audio or video and controls phone vibration. The name of a media file is specified in the Source property, which can be set in the Designer or in the Blocks Editor. The length of time for a vibration is specified in the Blocks Editor in milliseconds (thousandths of a second).

See Android Supported Media Formats for more information on which types of files you can use.

Use a player component for playing long sound files, video files, and vibrating the phone. For playing short sound files, such as sound effects, use a Sound component instead.

Properties
Source
Audio or video file associated with this player.
Methods
Pause()
Pauses playing the audio or video file.
Start()
Starts playing the audio or video file.
Stop()
Stops playing the audio or video file.
Vibrate(number milliseconds)
Activate the phone's vibration motor for the given number of milliseconds.
Sound

Use a sound component to play an audio file, or to vibrate the phone.

Sound is a non-visible component that plays sound files and vibrates for the number of milliseconds (thousandths of a second) specified in the Blocks Editor. The name of the sound file to play can be specified either in the Designer or in the Blocks Editor.

See Android Supported Media Formats for more information on which types of files you can use.

This component is best for short sound files, such as sound effects, while the Player component is more efficient for longer sounds, such as songs.

Properties
Source
Audio file associated with this sound.
MinimumInterval
Minimum time before sound is repeated.
Methods
Pause()
Pauses playing the audio file.
Play()
Starts playing the audio file.
Resume()
Resumes playing a paused audio file.
Stop()
Stops playing the audio file.
Vibrate(number millisecs)
Activate the phone's vibration motor for the given number of milliseconds.
VideoPlayer

Use a VideoPlayer component to play a video file.

Video player is a media component that plays videos. A video player appears in your app as a rectangle. If the user taps the rectangle, media controls appear: play/pause, skip ahead, and skip backward. Your app can control playback behavior by calling the Start, Pause, and Stop methods.

Video files should be in Windows Media Video (.wmv), 3GPP (.3gp), or MPEG-4 (.mp4) format. For more details about formats, see Android Supported Media Formats.

App Inventor accepts video files up to 1 MB in size and limits the total size of an app to 5 MB, not all of which is available for media files. If your media files are too large, you might get errors when packaging or installing your app, in which case you should reduce the number of media files or their sizes. Video editing software, such as Windows Movie Maker or Apple iMovie, can help you decrease the size of videos by shortening them or re-encoding them into more compact formats.

Properties
Source
Video file associated with this player.
Visible
If set, VideoPlayer is visible.
Methods
Pause()
Pauses playing the video file.
Start()
Starts playing the video file.
Stop()
Stops playing the video file.

  • 最終更新:2010-12-22 01:44:36

このWIKIを編集するにはパスワード入力が必要です

認証パスワード