Merge "Add TransportController API demo." into jb-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8439ba4536
@@ -309,5 +309,13 @@
|
||||
</provider>
|
||||
<!-- END_INCLUDE(file_provider_declaration) -->
|
||||
|
||||
<activity android:name=".media.TransportControllerActivity"
|
||||
android:label="@string/sample_transport_controller_activity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
14
samples/Support4Demos/res/layout/videoview.xml
Normal file
14
samples/Support4Demos/res/layout/videoview.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/surface_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
BIN
samples/Support4Demos/res/raw/videoviewdemo.mp4
Normal file
BIN
samples/Support4Demos/res/raw/videoviewdemo.mp4
Normal file
Binary file not shown.
@@ -133,15 +133,19 @@
|
||||
<string name="share_text">Share some text</string>
|
||||
<string name="share_file">Share a file</string>
|
||||
<string name="share_multiple_file">Share multiple files</string>
|
||||
<string name="sharing_support_title">ShareCompat Demo</string>
|
||||
<string name="sharing_support_title">App/ShareCompat Demo</string>
|
||||
<string name="sharing_receiver_title">ShareCompat Receiver</string>
|
||||
|
||||
<string name="file_provider_example">FileProvider example</string>
|
||||
<string name="file_provider_example">Content/FileProvider example</string>
|
||||
|
||||
<!-- Text API -->
|
||||
|
||||
<string name="without_bidiformatter">Without BidiFormatter:</string>
|
||||
<string name="with_bidiformatter">With BidiFormatter:</string>
|
||||
<string name="bidiformatter_support_title">BidiFormatter Demo</string>
|
||||
<string name="bidiformatter_support_title">Text/BidiFormatter Demo</string>
|
||||
|
||||
<!-- TransportController -->
|
||||
|
||||
<string name="sample_transport_controller_activity">Media/TransportController</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.android.supportv4.media;
|
||||
|
||||
import android.view.KeyEvent;
|
||||
import com.example.android.supportv4.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import android.support.v4.media.TransportController;
|
||||
|
||||
public class TransportControllerActivity extends Activity {
|
||||
|
||||
/**
|
||||
* TODO: Set the path variable to a streaming video URL or a local media
|
||||
* file path.
|
||||
*/
|
||||
private VideoView mVideoView;
|
||||
private TransportController mTransportController;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.videoview);
|
||||
|
||||
// Find the video player in our UI.
|
||||
mVideoView = (VideoView) findViewById(R.id.surface_view);
|
||||
|
||||
// Create transport controller to control video; use the standard
|
||||
// control callbacks that knows how to talk to a MediaPlayerControl.
|
||||
mTransportController = new TransportController(this,
|
||||
new TransportController.PlayerControlCallbacks(mVideoView));
|
||||
|
||||
// We're just playing a built-in demo video.
|
||||
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() +
|
||||
"/" + R.raw.videoviewdemo));
|
||||
mVideoView.setMediaController(new MediaController(this));
|
||||
mVideoView.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if (super.dispatchKeyEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the UI didn't handle the key, give the transport controller
|
||||
// a crack at it.
|
||||
return mTransportController.dispatchKeyEvent(event);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user