JAVA FILE : AndroidVideoPlayer.java
In this example showing code to play video. Taking a video(3gp) file inside application raw folder and playing in on activity.
Using VideoView class to load video from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting.

XML FILE : main.xml
Define VideoView as xml element to play video on activity.
<? xml version = "1.0" encoding = "utf-8" ?> < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:orientation = "vertical" android:layout_width = "fill_parent" android:layout_height = "fill_parent" > < TextView android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:text = "@string/hello" /> < Button android:id = "@+id/playvideoplayer" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:text = "- PLAY Video -" /> < VideoView android:id = "@+id/videoview" android:layout_width = "fill_parent" android:layout_height = "wrap_content" /> </ LinearLayout > |
XML FILE : AndroidManifest.xml
<? xml version = "1.0" encoding = "utf-8" ?> < manifest xmlns:android = "http://schemas.android.com/apk/res/android" package = "ru.android.AndroidVideoPlayer" android:versionCode = "1" android:versionName = "1.0" > < uses-sdk android:minSdkVersion = "10" /> < application android:icon = "@drawable/icon" android:label = "@string/app_name" > < activity android:name = ".AndroidVideoPlayer" android:label = "@string/app_name" > < intent-filter > < action android:name = "android.intent.action.MAIN" /> < category android:name = "android.intent.category.LAUNCHER" /> </ intent-filter > </ activity > </ application > </ manifest > |
Комментариев нет:
Отправить комментарий