VideoPlayer
Last Updated On 2021-07-16
Version 7MinSDK 7Tutorial Video
A multimedia component capable of playing videos. When the application is run, the VideoPlayer will be displayed as a rectangle on-screen. If the user touches the rectangle, controls will appear to play/pause, skip ahead, and skip backward within the video. The application can also control behavior by calling the Start
, Pause
, and SeekTo
methods.
Video files should be in 3GPP (.3gp) or MPEG-4 (.mp4) formats. For more details about legal formats, see Android Supported Media Formats.
App Inventor for Android only permits video files under 1 MB and limits the total size of an application to 5 MB, not all of which is available for media (video, audio, and sound) files. If your media files are too large, you may get errors when packaging or installing your application, in which case you should reduce the number of media files or their sizes. Most video editing software, such as Windows Movie Maker and Apple iMovie, can help you decrease the size of videos by shortening them or re-encoding the video into a more compact format.
You can also set the media source to a URL that points to a streaming video, but the URL must point to the video file itself, not to a program that plays the video.
Properties
You can set the below properties in the UI part of the builder.
- HeihMargin - it's a four value which is set to 0,0,0,0 by default.
- HeihPadding - it's a four value which is set to 0,0,0,0 by default.
- MarginBottom - it's a non negative float value which is set to 0 by default.
- MarginLeft - it's a non negative float value which is set to 0 by default.
- MarginRight - it's a non negative float value which is set to 0 by default.
- MarginTop - it's a non negative float value which is set to 0 by default.
- PaddingBottom - it's a non negative float value which is set to 0 by default.
- PaddingLeft - it's a non negative float value which is set to 0 by default.
- PaddingRight - it's a non negative float value which is set to 0 by default.
- PaddingTop - it's a non negative float value which is set to 0 by default.
- Source - it's a asset value which is set to blank by default.
- Visible - it's a visibility value which is set to true by default.
- Volume - it's a non negative float value which is set to 50 by default.
Block Properties
You can set the below blocks properties in the blocks section of the builder.
FullScreen
Returns whether the VideoPlayer's video is currently being shown in fullscreen mode or not.
Height
Specifies the component's vertical height, measured in pixels.
HeightPercent
Specifies the vertical height of the VideoPlayer as a percentage of the height of the Screen.
MarginBottom
Property for MarginBottom
MarginLeft
Property for MarginLeft
MarginRight
Property for MarginRight
MarginTop
Property for MarginTop
PaddingBottom
Property for PaddingBottom
PaddingLeft
Property for PaddingLeft
PaddingRight
Property for PaddingRight
PaddingTop
Property for PaddingTop
Source
The "path" to the video. Usually, this will be the name of the video file, which should be added in the Designer.
Visible
Specifies whether the VideoPlayer should be visible on the screen. Value is true if the VideoPlayer is showing and false if hidden.
Volume
Sets the volume to a number between 0 and 100. Values less than 0 will be treated as 0, and values greater than 100 will be treated as 100.
Width
Specifies the component's horizontal width, measured in pixels.
WidthPercent
Specifies the horizontal width of the VideoPlayer as a percentage of the width of the Screen.
Methods
You can set the below method blocks in the blocks section of the builder.
GetDuration
Returns duration of the video in milliseconds.
Pause
Pauses playback of the video. Playback can be resumed at the same location by calling the Start
method.
SeekTo
Seeks to the requested time (specified in milliseconds) in the video. If the video is paused, the frame shown will not be updated by the seek. The player can jump only to key frames in the video, so seeking to times that differ by short intervals may not actually move to different frames.
Start
Starts playback of the video.
Stop
Resets to start of video and pauses it if video was playing.
Events
You can set the below event blocks in the blocks section of the builder.
Completed
Indicates that the video has reached the end
VideoPlayerError
The VideoPlayerError event is no longer used. Please use the Screen.ErrorOccurred event instead.