USB 摄像头+远程遥控+中英的适配+topic的集成和状态的使用到相应页面
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
plugins {
|
||||
id "com.android.application"
|
||||
id "org.jetbrains.kotlin.android"
|
||||
id "dev.flutter.flutter-gradle-plugin"
|
||||
}
|
||||
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||
localProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '1'
|
||||
}
|
||||
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "io.flutter.plugins.videoplayerexample"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "io.flutter.plugins.videoplayerexample"
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig = signingConfigs.debug
|
||||
}
|
||||
}
|
||||
lint {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
}
|
||||
|
||||
flutter {
|
||||
source = '../..'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation("androidx.test.ext:junit:1.2.1")
|
||||
testImplementation("com.google.truth:truth:1.1.3")
|
||||
testImplementation("junit:junit:4.13")
|
||||
testImplementation("org.robolectric:robolectric:4.16")
|
||||
testImplementation("org.mockito:mockito-core:5.17.0")
|
||||
androidTestImplementation("androidx.test:runner:1.1.1")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.1.1")
|
||||
implementation(project(':espresso'))
|
||||
api("androidx.test:core:1.2.0")
|
||||
}
|
||||
6
packages/video_player_android/example/android/app/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
packages/video_player_android/example/android/app/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-all.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2013 The Flutter Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package io.flutter.plugins;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/*
|
||||
* Annotation to aid repository tooling in determining if a test is
|
||||
* a native java unit test or a java class with a dart integration.
|
||||
*
|
||||
* See: https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#enabling-android-ui-tests
|
||||
* for more information.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface DartIntegrationTest {}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2013 The Flutter Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package io.flutter.plugins.videoplayerexample;
|
||||
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
import dev.flutter.plugins.integration_test.FlutterTestRunner;
|
||||
import io.flutter.embedding.android.FlutterActivity;
|
||||
import io.flutter.plugins.DartIntegrationTest;
|
||||
import org.junit.Rule;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@DartIntegrationTest
|
||||
@RunWith(FlutterTestRunner.class)
|
||||
public class FlutterActivityTest {
|
||||
@Rule
|
||||
public ActivityTestRule<FlutterActivity> rule = new ActivityTestRule<>(FlutterActivity.class);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// Copyright 2013 The Flutter Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package io.flutter.plugins.videoplayerexample;
|
||||
|
||||
import static androidx.test.espresso.flutter.EspressoFlutter.WidgetInteraction;
|
||||
import static androidx.test.espresso.flutter.EspressoFlutter.onFlutterWidget;
|
||||
import static androidx.test.espresso.flutter.action.FlutterActions.click;
|
||||
import static androidx.test.espresso.flutter.assertion.FlutterAssertions.matches;
|
||||
import static androidx.test.espresso.flutter.matcher.FlutterMatchers.isExisting;
|
||||
import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withText;
|
||||
import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withValueKey;
|
||||
|
||||
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class VideoPlayerUITest {
|
||||
@Rule
|
||||
public ActivityScenarioRule<DriverExtensionActivity> activityRule =
|
||||
new ActivityScenarioRule<>(DriverExtensionActivity.class);
|
||||
|
||||
@Test
|
||||
@Ignore("Doesn't run in Firebase Test Lab: https://github.com/flutter/flutter/issues/94748")
|
||||
public void playVideo() {
|
||||
WidgetInteraction remoteTab = onFlutterWidget(withText("Remote"));
|
||||
remoteTab.check(matches(isExisting()));
|
||||
|
||||
for (String tabName : new String[] {"Platform view", "Texture view"}) {
|
||||
WidgetInteraction viewTypeTab = onFlutterWidget(withText(tabName));
|
||||
viewTypeTab.check(matches(isExisting()));
|
||||
viewTypeTab.perform(click());
|
||||
|
||||
WidgetInteraction playButton = onFlutterWidget(withValueKey("Play"));
|
||||
playButton.check(matches(isExisting()));
|
||||
playButton.perform(click());
|
||||
|
||||
WidgetInteraction playbackSpeed1x = onFlutterWidget(withText("1.0x"));
|
||||
playbackSpeed1x.check(matches(isExisting()));
|
||||
playbackSpeed1x.perform(click());
|
||||
|
||||
WidgetInteraction playbackSpeed5xButton = onFlutterWidget(withText("5.0x"));
|
||||
playbackSpeed5xButton.check(matches(isExisting()));
|
||||
playbackSpeed5xButton.perform(click());
|
||||
|
||||
WidgetInteraction playbackSpeed5x = onFlutterWidget(withText("5.0x"));
|
||||
playbackSpeed5x.check(matches(isExisting()));
|
||||
}
|
||||
|
||||
for (String[] tabData :
|
||||
new String[][] {{"Asset", "With assets mp4"}, {"Remote", "With remote mp4"}}) {
|
||||
String tabName = tabData[0];
|
||||
String videoDescription = tabData[1];
|
||||
WidgetInteraction tab = onFlutterWidget(withText(tabName));
|
||||
WidgetInteraction tabDescription = onFlutterWidget(withText(videoDescription));
|
||||
tab.check(matches(isExisting()));
|
||||
|
||||
// TODO(FirentisTFW): Assert that testDescription is not visible before we tap on tab.
|
||||
// This should be done once the Espresso API allows us to perform such an assertion. See
|
||||
// https://github.com/flutter/flutter/issues/160599
|
||||
|
||||
tab.perform(click());
|
||||
|
||||
tab.check(matches(isExisting()));
|
||||
tabDescription.check(matches(isExisting()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2013 The Flutter Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package io.flutter.plugins.videoplayerexample;
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity;
|
||||
|
||||
/** Test Activity that sets the name of the Dart method entrypoint in the manifest. */
|
||||
public class DriverExtensionActivity extends FlutterActivity {}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/white" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 544 B |
Binary file not shown.
|
After Width: | Height: | Size: 442 B |
Binary file not shown.
|
After Width: | Height: | Size: 721 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="true">www.sample-videos.com</domain>
|
||||
<domain includeSubdomains="true">184.72.239.149</domain>
|
||||
<!-- Needed for Espresso integration test -->
|
||||
<domain includeSubdomains="true">127.0.0.1</domain>
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright 2013 The Flutter Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package io.flutter.plugins.videoplayerexample;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.platform.PlatformViewRegistry;
|
||||
import io.flutter.plugins.videoplayer.VideoPlayerPlugin;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class FlutterActivityTest {
|
||||
AutoCloseable mockCloseable;
|
||||
@Mock FlutterPlugin.FlutterPluginBinding flutterPluginBinding;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
mockCloseable = MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
mockCloseable.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disposeAllPlayers() {
|
||||
when(flutterPluginBinding.getApplicationContext()).thenReturn(mock(Context.class));
|
||||
when(flutterPluginBinding.getBinaryMessenger()).thenReturn(mock(BinaryMessenger.class));
|
||||
when(flutterPluginBinding.getPlatformViewRegistry())
|
||||
.thenReturn(mock(PlatformViewRegistry.class));
|
||||
|
||||
VideoPlayerPlugin videoPlayerPlugin = spy(new VideoPlayerPlugin());
|
||||
|
||||
videoPlayerPlugin.onAttachedToEngine(flutterPluginBinding);
|
||||
videoPlayerPlugin.onDetachedFromEngine(flutterPluginBinding);
|
||||
verify(videoPlayerPlugin, times(1)).onDestroy();
|
||||
}
|
||||
}
|
||||
59
packages/video_player_android/example/android/build.gradle
Normal file
59
packages/video_player_android/example/android/build.gradle
Normal file
@@ -0,0 +1,59 @@
|
||||
allprojects {
|
||||
repositories {
|
||||
// See https://github.com/flutter/flutter/blob/master/docs/ecosystem/Plugins-and-Packages-repository-structure.md#gradle-structure for more info.
|
||||
def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY'
|
||||
if (System.getenv().containsKey(artifactRepoKey)) {
|
||||
println "Using artifact hub"
|
||||
maven { url System.getenv(artifactRepoKey) }
|
||||
}
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.buildDir = '../build'
|
||||
subprojects {
|
||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||
}
|
||||
subprojects {
|
||||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
// Build the plugin project with warnings enabled. This is here rather than
|
||||
// in the plugin itself to avoid breaking clients that have different
|
||||
// warnings (e.g., deprecation warnings from a newer SDK than this project
|
||||
// builds with).
|
||||
gradle.projectsEvaluated {
|
||||
project(":video_player_android") {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint:all" << "-Werror"
|
||||
|
||||
// Workaround for several warnings when building
|
||||
// that the above turns into errors, coming from
|
||||
// org.checkerframework.checker.nullness.qual and
|
||||
// com.google.errorprone.annotations:
|
||||
//
|
||||
// warning: Cannot find annotation method 'value()' in type
|
||||
// 'EnsuresNonNull': class file for
|
||||
// org.checkerframework.checker.nullness.qual.EnsuresNonNull not found
|
||||
//
|
||||
// warning: Cannot find annotation method 'replacement()' in type
|
||||
// 'InlineMe': class file for
|
||||
// com.google.errorprone.annotations.InlineMe not found
|
||||
//
|
||||
// The dependency version are taken from:
|
||||
// https://github.com/google/ExoPlayer/blob/r2.18.1/constants.gradle
|
||||
//
|
||||
// For future reference the dependencies are excluded here:
|
||||
// https://github.com/google/ExoPlayer/blob/r2.18.1/library/common/build.gradle#L33-L34
|
||||
dependencies {
|
||||
implementation("org.checkerframework:checker-qual:3.13.0")
|
||||
implementation("com.google.errorprone:error_prone_annotations:2.10.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
android.useAndroidX=true
|
||||
7
packages/video_player_android/example/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
packages/video_player_android/example/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#Fri Jun 23 08:50:38 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
pluginManagement {
|
||||
def flutterSdkPath = {
|
||||
def properties = new Properties()
|
||||
file("local.properties").withInputStream { properties.load(it) }
|
||||
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||
return flutterSdkPath
|
||||
}()
|
||||
|
||||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
// See https://github.com/flutter/flutter/blob/master/docs/ecosystem/Plugins-and-Packages-repository-structure.md#gradle-structure for more info.
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "8.11.1" apply false
|
||||
id "org.jetbrains.kotlin.android" version "2.2.20" apply false
|
||||
id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1"
|
||||
}
|
||||
|
||||
include ":app"
|
||||
BIN
packages/video_player_android/example/assets/Butterfly-209.mp4
Normal file
BIN
packages/video_player_android/example/assets/Butterfly-209.mp4
Normal file
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 482 B |
36
packages/video_player_android/example/pubspec.yaml
Normal file
36
packages/video_player_android/example/pubspec.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
name: video_player_example
|
||||
description: Demonstrates how to use the video_player plugin.
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.0
|
||||
flutter: ">=3.35.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
video_player_android:
|
||||
# When depending on this package from a real application you should use:
|
||||
# video_player_android: ^x.y.z
|
||||
# See https://dart.dev/tools/pub/dependencies#version-constraints
|
||||
# The example app is bundled with the plugin so we use a path dependency on
|
||||
# the parent directory to use the current plugin's version.
|
||||
path: ../
|
||||
video_player_platform_interface: ^6.6.0
|
||||
|
||||
dev_dependencies:
|
||||
espresso: ^0.4.0
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
integration_test:
|
||||
sdk: flutter
|
||||
path_provider: ^2.0.6
|
||||
test: any
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- assets/flutter-mark-square-64.png
|
||||
- assets/Butterfly-209.mp4
|
||||
Reference in New Issue
Block a user