视频结束时致电下一个活动

时间:2019-03-17 18:23:26

标签: android android-intent android-activity android-videoview

我是Android开发的新手,我正在开发一个应用程序,我希望在该应用程序中,当在activity_1的视频视图中播放的视频结束时,activity_2自动启动。

2 个答案:

答案 0 :(得分:0)

是的,您可以使用OnCompletionListener如下:

videoView.setOnCompletionListener(new OnCompletionListener() {
    @Override
    public void onCompletion(MediaPlayer mp) {
        // start your next activity from here
    }
});

答案 1 :(得分:0)

假设您有一个名为videoView的VideoView(VideoView类的实例),然后在其上调用波纹管函数:

  Using cached https://files.pythonhosted.org/packages/61/ab/2ac6dea8489fa713e2b4c6c5b549cc962dd4a842b5998d9e80cf8440b7cd/PyNaCl-1.3.0.tar.gz
  Installing build dependencies ... error
  Complete output from command /usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-yrmcivln --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel "cffi>=1.4.1; python_implementation != 'PyPy'":
  Collecting setuptools
    Using cached https://files.pythonhosted.org/packages/d1/6a/4b2fcefd2ea0868810e92d519dacac1ddc64a2e53ba9e3422c3b62b378a6/setuptools-40.8.0-py2.py3-none-any.whl
  Collecting wheel
    Using cached https://files.pythonhosted.org/packages/96/ba/a4702cbb6a3a485239fbe9525443446203f00771af9ac000fa3ef2788201/wheel-0.33.1-py2.py3-none-any.whl
  Collecting cffi>=1.4.1
    Using cached https://files.pythonhosted.org/packages/64/7c/27367b38e6cc3e1f49f193deb761fe75cda9f95da37b67b422e62281fcac/cffi-1.12.2.tar.gz
  Collecting pycparser (from cffi>=1.4.1)
    Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
  Installing collected packages: setuptools, wheel, pycparser, cffi
    Running setup.py install for pycparser: started
      Running setup.py install for pycparser: finished with status 'done'
    Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-hvzwh_xy/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-sq8m4eeo/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-yrmcivln --compile:
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-3.7
      creating build/lib.linux-aarch64-3.7/cffi
      copying cffi/recompiler.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/verifier.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/__init__.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/lock.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/api.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/cparser.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/error.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/commontypes.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/model.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/_embedding.h -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-3.7/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-aarch64-3.7
      creating build/temp.linux-aarch64-3.7/c
      gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/python3.7m -c c/_cffi_backend.c -o build/temp.linux-aarch64-3.7/c/_cffi_backend.o
      c/_cffi_backend.c:2:10: fatal error: Python.h: No such file or directory
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      error: command 'gcc' failed with exit status 1

      ----------------------------------------
  Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-hvzwh_xy/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-sq8m4eeo/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-yrmcivln --compile" failed with error code 1 in /tmp/pip-install-hvzwh_xy/cffi/

  ----------------------------------------
Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-yrmcivln --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel "cffi>=1.4.1; python_implementation != 'PyPy'"" failed with error code 1 in None

YourTargetActivity =>您要开始的活动。


文件: 如何start another activity, 和VideoView的文档:

VideoView's doc image