2017年5月14日 星期日

EXOPlayer's surface view


  /**
   * Sets the {@link SurfaceView} onto which video will be rendered. The player will track the
   * lifecycle of the surface automatically.
   *
   * @param surfaceView The surface view.
   */
  public void setVideoSurfaceView(SurfaceView surfaceView) {
    setVideoSurfaceHolder(surfaceView.getHolder());
  }



https://developer.android.com/reference/android/media/MediaCodec.html#setOutputSurface(android.view.Surface)

 // Create a surface view and insert it into the content frame, if there is one.
    if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) {
      ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
          ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
      surfaceView = surfaceType == SURFACE_TYPE_TEXTURE_VIEW ? new TextureView(context)
          : new SurfaceView(context);
      surfaceView.setLayoutParams(params);
      contentFrame.addView(surfaceView, 0);
    } else {
      surfaceView = null;
    }


 

Preview seek bar

    @Override
    public void loadPreview(long currentPosition, long max) {
        float offset = (float) currentPosition / max;
        int scale = player.getDuration() >= ROUND_DECIMALS_THRESHOLD ? 2 : 1;
        float offsetRounded = roundOffset(offset, scale);
        player.setPlayWhenReady(false);
        previewPlayer.seekTo((long) (offsetRounded * previewPlayer.getDuration()));
        previewPlayer.setPlayWhenReady(false);
        View view = previewPlayerView.getVideoSurfaceView();
        if (view instanceof SurfaceView) {
            view.setVisibility(View.VISIBLE);
        }
    }

2017年5月7日 星期日

exoplayer佈局原理

exo_simple_player_view.xml

  <View android:id="@id/exo_controller_placeholder"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/>

-------------------------


    View controllerPlaceholder = findViewById(R.id.exo_controller_placeholder);
    if (controllerPlaceholder != null) {
      // Note: rewindMs and fastForwardMs are passed via attrs, so we don't need to make explicit
      // calls to set them.
      this.controller = new PlaybackControlView(context, attrs);
      controller.setLayoutParams(controllerPlaceholder.getLayoutParams());
      ViewGroup parent = ((ViewGroup) controllerPlaceholder.getParent());
      int controllerIndex = parent.indexOfChild(controllerPlaceholder);
      parent.removeView(controllerPlaceholder);
      parent.addView(controller, controllerIndex);
    } else {
      this.controller = null;
    }

-------------------------

exo_controller_placeholder

--------------------------




http://fecbob.pixnet.net/blog/post/35999655-%5Bandroid%5D-expandablelistview%E7%B0%A1%E5%96%AE%E7%94%A8%E6%B3%95

意圖和意圖篩選器


https://developer.android.com/guide/components/intents-filters.html?hl=zh-tw


















好的說明範例!!!

[Andriod] 透過setContentView轉換layout


https://dotblogs.com.tw/psjhuo/2013/04/18/101805



---------------------------------------
























https://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW










    // Playback control view.
    View controllerPlaceholder = findViewById(R.id.exo_controller_placeholder);
    if (controllerPlaceholder != null) {
      // Note: rewindMs and fastForwardMs are passed via attrs, so we don't need to make explicit
      // calls to set them.
      this.controller = new PlaybackControlView(context, attrs);
      controller.setLayoutParams(controllerPlaceholder.getLayoutParams());
      ViewGroup parent = ((ViewGroup) controllerPlaceholder.getParent());
      int controllerIndex = parent.indexOfChild(controllerPlaceholder);
      parent.removeView(controllerPlaceholder);
      parent.addView(controller, controllerIndex);
    } else {
      this.controller = null;
    }



Step 1:
Intent intent = new Intent(context, PlayerActivity.class);


Step 2:
    @Override
    public Intent buildIntent(Context context) {
      return super.buildIntent(context)
          .setData(Uri.parse(uri))
          .putExtra(PlayerActivity.EXTENSION_EXTRA, extension)
          .setAction(PlayerActivity.ACTION_VIEW);
    }

Step 3:
    @Override
    protected void onPostExecute(List<SampleGroup> result) {

      Log.d(TAG1, "onPostExecute() thread = " + Thread.currentThread().getId()); 
 
      onSampleGroups(result, sawError);
    }
如何從SampleChooserActivity 轉到 PlayerActivity











Q1: SimpleExoPlayerView怎麼來的?


2017年1月20日 星期五

WebView & HTML print

https://www.quora.com/What-is-the-Android-system-WebView-app-and-how-can-I-use-it

Camera record

[出處以及原始程式]

http://www.techotopia.com/index.php/Video_Recording_and_Image_Capture_on_Android_using_Camera_Intents

[解釋]

https://developer.android.com/guide/components/intents-filters.html?hl=zh-tw

如何啟動 Activity:
Activity 代表應用程式中的單一畫面。您可以將 Intent 傳送至 startActivity() 來啟動 Activity 的新執行個體。 Intent 可描述要啟動的 Activity 並攜帶任何必要資料。
如果您想要在 Activity 完成時收到結果, 請呼叫 startActivityForResult()。Activity 的 onActivityResult()回呼中的個別 Intent 物件,就是 Activity 收到的結果。 如需詳細資訊,請參閱 Activity 指南。


https://developer.android.com/training/basics/intents/result.html

啟動其他應用行為顯示不必是單向作業。您也可以啟動其他應用行為顯示,然後接收傳回的結果。 若要接收結果,請呼叫 startActivityForResult() (而非 startActivity())。
例如,您的應用程式可以啟動相機應用程式,然後接收所拍攝的相片作為結果。或者,您可以啟動人員應用程式 (以便讓使用者選取連絡人),然後接收作為結果的連絡人詳細資料。
當然,必須將提供回應的應用行為顯示設計為傳回結果。執行時,該應用行為顯示會以其他 Intent 物件的形式傳送結果。 您的應用行為顯示會在 onActivityResult() 回呼中接收該結果。
注意:呼叫 startActivityForResult() 時,您可以使用明確或隱含的意圖。 啟動您的其中一個應用行為顯示以接收結果時,您應使用明確的意圖,以確保收到預期結果。