diff --git a/samples/Support4Demos/AndroidManifest.xml b/samples/Support4Demos/AndroidManifest.xml index 99bacd482..8d20c9efd 100644 --- a/samples/Support4Demos/AndroidManifest.xml +++ b/samples/Support4Demos/AndroidManifest.xml @@ -309,5 +309,13 @@ + + + + + + + diff --git a/samples/Support4Demos/res/layout/videoview.xml b/samples/Support4Demos/res/layout/videoview.xml new file mode 100644 index 000000000..ff636b99a --- /dev/null +++ b/samples/Support4Demos/res/layout/videoview.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/samples/Support4Demos/res/raw/videoviewdemo.mp4 b/samples/Support4Demos/res/raw/videoviewdemo.mp4 new file mode 100644 index 000000000..57728106d Binary files /dev/null and b/samples/Support4Demos/res/raw/videoviewdemo.mp4 differ diff --git a/samples/Support4Demos/res/values/strings.xml b/samples/Support4Demos/res/values/strings.xml index 977db2f64..d0e096a4c 100644 --- a/samples/Support4Demos/res/values/strings.xml +++ b/samples/Support4Demos/res/values/strings.xml @@ -133,15 +133,19 @@ Share some text Share a file Share multiple files - ShareCompat Demo + App/ShareCompat Demo ShareCompat Receiver - FileProvider example + Content/FileProvider example Without BidiFormatter: With BidiFormatter: - BidiFormatter Demo + Text/BidiFormatter Demo + + + + Media/TransportController diff --git a/samples/Support4Demos/src/com/example/android/supportv4/media/TransportControllerActivity.java b/samples/Support4Demos/src/com/example/android/supportv4/media/TransportControllerActivity.java new file mode 100644 index 000000000..58e54f091 --- /dev/null +++ b/samples/Support4Demos/src/com/example/android/supportv4/media/TransportControllerActivity.java @@ -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); + } +}