package fm.jiecao.jiecaovideoplayer; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import com.squareup.picasso.Picasso; import fm.jiecao.jcvideoplayer_lib.JCUserAction; import fm.jiecao.jcvideoplayer_lib.JCUserActionStandard; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; /** * Created by Nathen on 16/7/22. */ public class MainActivity extends AppCompatActivity implements View.OnClickListener { JCVideoPlayerStandard mJcVideoPlayerStandard; Button mTinyWindow, mAutoTinyWindow, mAboutListView, mPlayDirectly, mAboutApi, mAboutWebView; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTinyWindow = (Button) findViewById(R.id.tiny_window); mAutoTinyWindow = (Button) findViewById(R.id.auto_tiny_window); mPlayDirectly = (Button) findViewById(R.id.play_directly_without_layout); mAboutListView = (Button) findViewById(R.id.about_listview); mAboutApi = (Button) findViewById(R.id.about_api); mAboutWebView = (Button) findViewById(R.id.about_webview); mTinyWindow.setOnClickListener(this); mAutoTinyWindow.setOnClickListener(this); mAboutListView.setOnClickListener(this); mPlayDirectly.setOnClickListener(this); mAboutApi.setOnClickListener(this); mAboutWebView.setOnClickListener(this); mJcVideoPlayerStandard = (JCVideoPlayerStandard) findViewById(R.id.jc_video); mJcVideoPlayerStandard.setUp("http://video.jiecao.fm/11/23/xin/%E5%81%87%E4%BA%BA.mp4" , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子不信"); Picasso.with(this) .load("http://img4.jiecaojingxuan.com/2016/11/23/00b026e7-b830-4994-bc87-38f4033806a6.jpg@!640_360") .into(mJcVideoPlayerStandard.thumbImageView); JCVideoPlayer.setJcUserAction(new MyUserActionStandard()); } @Override protected void onPause() { super.onPause(); JCVideoPlayer.releaseAllVideos(); } @Override public void onBackPressed() { if (JCVideoPlayer.backPress()) { return; } super.onBackPressed(); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.tiny_window: mJcVideoPlayerStandard.startWindowTiny(); break; case R.id.auto_tiny_window: startActivity(new Intent(MainActivity.this, AutoTinyActivity.class)); break; case R.id.play_directly_without_layout: startActivity(new Intent(MainActivity.this, PlayDirectlyActivity.class)); break; case R.id.about_listview: startActivity(new Intent(MainActivity.this, ListViewActivity.class)); break; case R.id.about_api: startActivity(new Intent(MainActivity.this, ApiActivity.class)); break; case R.id.about_webview: startActivity(new Intent(MainActivity.this, WebViewActivity.class)); break; } } class MyUserActionStandard implements JCUserActionStandard { @Override public void onEvent(int type, String url, int screen, Object... objects) { switch (type) { case JCUserAction.ON_CLICK_START_ICON: Log.i("USER_EVENT", "ON_CLICK_START_ICON" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_CLICK_START_ERROR: Log.i("USER_EVENT", "ON_CLICK_START_ERROR" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_CLICK_START_AUTO_COMPLETE: Log.i("USER_EVENT", "ON_CLICK_START_AUTO_COMPLETE" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_CLICK_PAUSE: Log.i("USER_EVENT", "ON_CLICK_PAUSE" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_CLICK_RESUME: Log.i("USER_EVENT", "ON_CLICK_RESUME" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_SEEK_POSITION: Log.i("USER_EVENT", "ON_SEEK_POSITION" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_AUTO_COMPLETE: Log.i("USER_EVENT", "ON_AUTO_COMPLETE" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_ENTER_FULLSCREEN: Log.i("USER_EVENT", "ON_ENTER_FULLSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_QUIT_FULLSCREEN: Log.i("USER_EVENT", "ON_QUIT_FULLSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_ENTER_TINYSCREEN: Log.i("USER_EVENT", "ON_ENTER_TINYSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_QUIT_TINYSCREEN: Log.i("USER_EVENT", "ON_QUIT_TINYSCREEN" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_TOUCH_SCREEN_SEEK_VOLUME: Log.i("USER_EVENT", "ON_TOUCH_SCREEN_SEEK_VOLUME" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserAction.ON_TOUCH_SCREEN_SEEK_POSITION: Log.i("USER_EVENT", "ON_TOUCH_SCREEN_SEEK_POSITION" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserActionStandard.ON_CLICK_START_THUMB: Log.i("USER_EVENT", "ON_CLICK_START_THUMB" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; case JCUserActionStandard.ON_CLICK_BLANK: Log.i("USER_EVENT", "ON_CLICK_BLANK" + " title is : " + (objects.length == 0 ? "" : objects[0]) + " url is : " + url + " screen is : " + screen); break; default: Log.i("USER_EVENT", "unknow"); break; } } } }