Auto rotate fullscreen video in android -
i newbie, , trying make simple application can play video url. able play video in app, want auto rotate,hide actionbar title , fullscreen when click button fullscreen.
this manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="htantruc.videotest"> <uses-permission android:name="android.permission.internet" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/theme.appcompat.light.noactionbar.fullscreen"> <activity android:name=".video" android:configchanges="orientation|screensize"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".videoviewactivity" android:configchanges="orientation|screensize"></activity> </application> </manifest>
and xml:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".videoviewactivity" android:theme="@style/customactivitythemenoactionbar"> <framelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginbottom="250dp" android:layout_alignparentright="true" android:layout_alignparentend="true"> <com.github.rtoshiro.view.video.fullscreenvideolayout android:id="@+id/videoview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </framelayout> </relativelayout>
display display = getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); int width = size.x; int height = size.y;
if you're not in activity can default display via window_service:
windowmanager wm = (windowmanager) context.getsystemservice(context.window_service); display display = wm.getdefaultdisplay();
before getsize introduced (in api level 13), use getwidth , getheight methods deprecated:
display display = getwindowmanager().getdefaultdisplay(); int width = display.getwidth(); // deprecated int height = display.getheight(); // deprecated
how set width , height
videoview.getholder().setfixedsize(width, height);
call same code in activity , onconfigurationchanged()
Comments
Post a Comment