<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.cj5785.ffmpegnativeplayer.view.MySurfaceView
android:id="@+id/surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始"
android:onClick="mPlay" />
</FrameLayout>
package com.cj5785.ffmpegnativeplayer.view;
import android.content.Context;
import android.graphics.PixelFormat;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class MySurfaceView extends SurfaceView {
public MySurfaceView(Context context) {
super(context);
init();
}
public MySurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MySurfaceView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
//初始化像素格式
private void init() {
SurfaceHolder holder = getHolder();
holder.setFormat(PixelFormat.RGBA_8888);
}
}│ Android.mk
│ Application.mk
│ com_cj5785_ffmpegnativeplayer_NativePlayer.h
│ ffmpeg_native_player.c
│
└─include
├─ffmpeg
│ │ libavcodec-56.so
│ │ libavdevice-56.so
│ │ libavfilter-5.so
│ │ libavformat-56.so
│ │ libavutil-54.so
│ │ libpostproc-53.so
│ │ libswresample-1.so
│ │ libswscale-3.so
│ │
│ ├─libavcodec
│ ├─libavdevice
│ ├─libavfilter
│ ├─libavformat
│ ├─libavutil
│ ├─libpostproc
│ ├─libswresample
│ └─libswscale
│
└─libyuv
│ libyuv.h
│ libyuv.so
│
└─libyuv
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := avcodec
LOCAL_SRC_FILES := include/ffmpeg/libavcodec-56.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := avdevice
LOCAL_SRC_FILES := include/ffmpeg/libavdevice-56.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := avfilter
LOCAL_SRC_FILES := include/ffmpeg/libavfilter-5.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := avformat
LOCAL_SRC_FILES := include/ffmpeg/libavformat-56.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := avutil
LOCAL_SRC_FILES := include/ffmpeg/libavutil-54.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := postproc
LOCAL_SRC_FILES := include/ffmpeg/libpostproc-53.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := swresample
LOCAL_SRC_FILES := include/ffmpeg/libswresample-1.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := swscale
LOCAL_SRC_FILES := include/ffmpeg/libswscale-3.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := yuv
LOCAL_SRC_FILES := include/libyuv/libyuv.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg_native_player
LOCAL_SRC_FILES := ffmpeg_native_player.c
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ffmpeg
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/libyuv
LOCAL_LDLIBS := -llog -landroid
LOCAL_SHARED_LIBRARIES := avcodec avdevice avfilter avformat avutil postproc swresample swscale yuv
include $(BUILD_SHARED_LIBRARY)
package com.cj5785.ffmpegnativeplayer;
import java.io.File;
import com.cj5785.ffmpegnativeplayer.view.MySurfaceView;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.Surface;
import android.view.View;
public class MainActivity extends Activity {
private NativePlayer player;
private MySurfaceView mySurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mySurfaceView = (MySurfaceView) findViewById(R.id.surface_view);
player = new NativePlayer();
}
public void mPlay(View view) {
String input = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separatorChar + "oneplus.mp4";
Surface surface = mySurfaceView.getHolder().getSurface();
player.render(input, surface);
}
}
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.cj5785.ffmpegnativeplayer.view.MySurfaceView
android:id="@+id/surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:id="@+id/sp_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始"
android:onClick="mPlay" />
</LinearLayout>
</FrameLayout>
class DialogWindow(QDialog, Ui_Dialog):
def __init__(self, parent=None):
super(DialogWindow, self).__init__(parent)
self.setupUi(self)
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
def open_dialog(self):
dialog = DialogWindow(self)
dialog.show()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
sys.exit(app.exec_())
class DialogWindow(QDialog, Ui_Dialog):
stop_thread = pyqtSignal() # 定义关闭子线程的信号
def __init__(self, parent=None):
super(DialogWindow, self).__init__(parent)
self.setupUi(self)
def update_progressbar(self, p_int):
self.progressBar.setValue(p_int)
def closeEvent(self, event):
self.stop_thread.emit()
pass
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.count = 0
def open_dialog(self):
dialog = DialogWindow(self)
dialog.show()
self.thread = RunThread(self.count)
self.count += 1
self.thread.update_pb.connect(dialog.update_progressbar)
dialog.stop_thread.connect(self.thread.terminate)
self.thread.start()
class RunThread(QThread):
update_pb = pyqtSignal(int)
def __init__(self, count):
super().__init__()
self.count = count
def run(self):
for i in range(1, 101):
print('thread_%s' % self.count, i, QThread().currentThreadId())
self.update_pb.emit(i)
time.sleep(1)
pass
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
sys.exit(app.exec_())package KnowAll;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class KnowAllPanel extends JFrame{
public KnowAllPanel() {
showPanel();
}
JButton findIP = new JButton(" 查 询 I P ");
JButton findMyIP = new JButton("查询自己的IP地址");
JButton findID = new JButton("查询身份证号");
JButton findNUMBER = new JButton("查询手机号码");
JTextArea myIP = new JTextArea(2, 25);
public void showPanel() {
this.setTitle("百事通");
this.setSize(410, 450);// 左长右高
this.setLocation(500, 70);// 左水平又竖直
this.setResizable(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setLayout(new FlowLayout(FlowLayout.CENTER));//流式布局
//添加图标并设置尺寸
int width = 100;
int height = 100;
ImageIcon findIdNumber_img = new ImageIcon("img\\idcard.jpg");
Image findIdNumber = findIdNumber_img.getImage();
findIdNumber = findIdNumber.getScaledInstance(width, height, Image.SCALE_DEFAULT);
findIdNumber_img.setImage(findIdNumber);
JLabel id = new JLabel(findIdNumber_img,JLabel.CENTER);
id.setSize(width, height);
ImageIcon findIp_img = new ImageIcon("img\\ip.jpg");
Image findIp = findIp_img.getImage();
findIp = findIp.getScaledInstance(width, height, Image.SCALE_DEFAULT);
findIp_img.setImage(findIp);
JLabel ip = new JLabel(findIp_img,JLabel.CENTER);
ip.setSize(width, height);
ImageIcon findPhoneNumber_img = new ImageIcon("img\\phonenumber.jpg");
Image findNumber = findPhoneNumber_img.getImage();
findNumber = findNumber.getScaledInstance(width, height, Image.SCALE_DEFAULT);
findPhoneNumber_img.setImage(findNumber);
JLabel phoneNumber = new JLabel(findPhoneNumber_img,JLabel.CENTER);
phoneNumber.setSize(width, height);
//将图标、按钮添加到面板
JPanel jp1 = new JPanel();
jp1.add(ip);
this.add(jp1);
JPanel jp2 = new JPanel();
jp2.add(id);
this.add(jp2);
JPanel jp3 = new JPanel();
jp3.add(phoneNumber);
this.add(jp3);
JPanel jp4 = new JPanel();
jp4.add(findIP);
jp4.add(findID);
jp4.add(findNUMBER);
JPanel jp5 = new JPanel();
jp5.add(findMyIP);
this.add(jp4);
this.add(jp5);
JPanel jp6 = new JPanel();
myIP.setEditable(false);
jp6.add(myIP);
this.add(jp6);
//按钮添加监听
findIP.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
setVisible(false);
FindipPanel panel = new FindipPanel();
dispose();
}
});
findID.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
setVisible(false);
FindidPanel panel = new FindidPanel();
dispose();
}
});
findNUMBER.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
setVisible(false);
FindPhoneNumberPanel panel = new FindPhoneNumberPanel();
dispose();
}
});
findMyIP.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
myIP.setText("");
myIP.setText(InquireIpFunction.getMyIpFromContent());
}
});
}
public static void main(String[] args) {
KnowAllPanel panel = new KnowAllPanel();
}
}