Android QPython3 擴(kuò)展:視頻播放
#需要QPythonSupport基礎(chǔ)窗口??https://www.bilibili.com/read/cv9100444
【QPythonSupport/app/src/main/AndroidManifest.xml】添加
? ? ? ? <activity
? ? ? ? ? ? android:label="視頻播放器"
? ? ? ? ? ? android:name=".Video"
? ? ? android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
? ?<intent-filter>
? ? ? ? ? ? ? ? <action android:name="android.intent.action.VIEW" />
? ? ? ? ? ? </intent-filter>
? ? ? ? </activity>
〖備注〗
真全屏:android:style/Theme.NoTitleBar.Fullscreen
準(zhǔn)全屏:android:style/Theme.NoTitleBar
【QPythonSupport/app/src/main/res/layout/video.xml】
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:gravity="center"
? ? android:orientation="vertical" >
? ? <VideoView
? ? ? ? android:id="@+id/videoView"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="match_parent" />
</LinearLayout>
【QPythonSupport/app/src/main/java/czc/qpython/support/Video.java】
package czc.qpython.support;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.text.*;
import java.io.*;
import android.net.*;
import android.content.*;
public class Video extends Activity
?{
? ? @Override
? ? public void onCreate(Bundle savedInstanceState) {
? Main.requestPermissions(this);
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.video);
? Intent intent=getIntent();
? String path=intent.getStringExtra("path");
? ? ? ? VideoView videoView=(VideoView)findViewById(R.id.videoView);
? videoView.setVideoPath(path);
? ? ? ? MediaController mediaController=new MediaController(this);
? mediaController.setAnchorView(mediaController);
? videoView.start();
? videoView.setMediaController(mediaController);
? ? }
}
【QPythonSupport/__init__.py】添加
def VideoPlay(Path,Wait=True):
? ? jsla('startActivity','android.intent.action.VIEW',None,None,{'path':Path},Wait,'czc.qpython.support','czc.qpython.support.Video')
【QPythonSupport/說明.txt】添加
? VideoPlay(Path,Wait=True)
? 視頻播放(路徑,等待=是)

視頻:https://www.bilibili.com/video/BV1zK411g7KB
作者:乘著船@Bilibili
更多文章+下載鏈接:https://www.bilibili.com/read/readlist/rl321663