[android] added video view example (#6198)
* [android] added video view example * removed map ready callback
This commit is contained in:
@@ -300,6 +300,14 @@
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_fragment" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.VideoViewActivity"
|
||||
android:description="@string/description_video_view"
|
||||
android:label="@string/activity_video_view">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.RuntimeStyleActivity"
|
||||
android:description="@string/description_runtime_style"
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import static android.media.MediaPlayer.*;
|
||||
|
||||
public class VideoViewActivity extends AppCompatActivity {
|
||||
|
||||
private MapView mapView;
|
||||
private VideoView videoView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_video_view);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
// Setup the video
|
||||
videoView = (VideoView) findViewById(R.id.video_view);
|
||||
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sea_waves));
|
||||
videoView.start();
|
||||
|
||||
// Used to repeat the video.
|
||||
videoView.setOnPreparedListener(new OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mediaPlayer) {
|
||||
mediaPlayer.setLooping(true);
|
||||
}
|
||||
});
|
||||
|
||||
mapView = (MapView) findViewById(R.id.map_view);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.maplayout.VideoViewActivity">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/primary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/video_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_margin="16dp"/>
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/map_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/toolbar"
|
||||
mapbox:center_latitude="34.4021"
|
||||
mapbox:center_longitude="-119.7081"
|
||||
mapbox:attribution_gravity="top"
|
||||
mapbox:logo_gravity="top"
|
||||
mapbox:style_url="mapbox://styles/mapbox/streets-v9"
|
||||
mapbox:zoom="13"/>
|
||||
|
||||
</RelativeLayout>
|
||||
Binary file not shown.
@@ -63,6 +63,7 @@
|
||||
<string name="activity_query_rendered_features_box_highlight">Highlight features in box</string>
|
||||
<string name="activity_circle">Add Circle</string>
|
||||
<string name="activity_navigation_drawer">Android SDK View integration</string>
|
||||
<string name="activity_video_view">Video View</string>
|
||||
|
||||
<!-- Description -->
|
||||
<string name="description_user_location_tracking">Tracks the location of the user</string>
|
||||
@@ -110,6 +111,7 @@
|
||||
<string name="description_query_rendered_features_box_count">Count all rendered features in box</string>
|
||||
<string name="description_query_rendered_features_box_highlight">Hightligh buildings in box</string>
|
||||
<string name="description_car_driving">MyLocationView follow map update example</string>
|
||||
<string name="description_video_view">Android video view on top of the map view</string>
|
||||
|
||||
<string name="menuitem_title_concurrent_infowindow">Concurrent Open InfoWindows</string>
|
||||
<string name="menuitem_title_deselect_markers_on_tap">Deselect Markers On Tap</string>
|
||||
|
||||
Reference in New Issue
Block a user