|
|
@@ -1,7 +1,11 @@
|
|
|
package com.example.david.myapplication;
|
|
|
+import android.app.Activity;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
import android.support.annotation.Nullable;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
+import android.support.v4.app.FragmentActivity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
@@ -17,11 +21,20 @@ import io.vov.vitamio.widget.VideoView;
|
|
|
/**
|
|
|
* Created by david on 16/04/16.
|
|
|
*/
|
|
|
+
|
|
|
public class videoFragment extends Fragment implements diapoListener {
|
|
|
private static final String path = "rtmp://plataforma.especificosba.com.ar:1935/src/movie";
|
|
|
- private static final String default_image = "https://plataforma.especificosba.com.ar/diapo/EBA/1.png";
|
|
|
- private VideoView mVideoView;
|
|
|
- private ImageView image;
|
|
|
+ private static final String diapo_template = "https://plataforma.especificosba.com.ar/diapo/%s/%d.png";
|
|
|
+ private static VideoView mVideoView;
|
|
|
+ private static ImageView image;
|
|
|
+ private static Diapositiva d;
|
|
|
+ protected static FragmentActivity mActivity;
|
|
|
+ Handler h = new Handler(){
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg){
|
|
|
+ loadImage(uriFromDiapo(d));
|
|
|
+ }
|
|
|
+ };
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
Bundle savedInstanceState) {
|
|
|
@@ -29,12 +42,19 @@ public class videoFragment extends Fragment implements diapoListener {
|
|
|
return rootView;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onAttach(Activity activity) {
|
|
|
+ super.onAttach(activity);
|
|
|
+ mActivity = (FragmentActivity)activity;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
mVideoView = (VideoView) getView().findViewById(R.id.vitamio_videoView);
|
|
|
image= (ImageView) getView().findViewById(R.id.imageView);
|
|
|
- Picasso.with(getActivity().getApplicationContext()).load(default_image).into(image);
|
|
|
+ d= new Diapositiva(1,"EBA");
|
|
|
+ loadImage(uriFromDiapo(d));
|
|
|
|
|
|
|
|
|
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
|
|
@@ -47,7 +67,30 @@ public class videoFragment extends Fragment implements diapoListener {
|
|
|
mVideoView.start();
|
|
|
}
|
|
|
@Override
|
|
|
- public void msgReceived(String PDF, String diapo, int slide){
|
|
|
- Log.i("WebsocketPDF" + PDF + diapo + Integer.toString(slide));
|
|
|
+ public void msgReceived(String PDF, int slide){
|
|
|
+ d = new Diapositiva(slide,PDF);
|
|
|
+ Log.i("WebsocketPDF" + PDF + Integer.toString(slide));
|
|
|
+ h.sendEmptyMessage(0);
|
|
|
+ if(mActivity==null)
|
|
|
+ return;
|
|
|
+ Picasso.with(mActivity.getApplicationContext()).load(uriFromDiapo(d)).into(image);
|
|
|
+
|
|
|
+ /*Picasso.with(getApplicationContext())
|
|
|
+ .load(url)
|
|
|
+ .resizeDimen(R.dimen.article_image_preview_width, R.dimen.article_image_preview_height)
|
|
|
+ .centerCrop()
|
|
|
+ .fetch();*/
|
|
|
+ }
|
|
|
+ private String uriFromDiapo(Diapositiva dd) {
|
|
|
+ return String.format(diapo_template, dd.PDF,dd.page );
|
|
|
+ }
|
|
|
+ private void loadImage(String uri){
|
|
|
+ if(image==null)
|
|
|
+ return;
|
|
|
+ if(mActivity==null)
|
|
|
+ return;
|
|
|
+ Log.i("WebsocketURL", uri);
|
|
|
+ Picasso.with(mActivity.getApplicationContext()).load(uri).into(image);
|
|
|
+ Picasso.with(mActivity.getApplicationContext()).load(uriFromDiapo(new Diapositiva(d.page+1,d.PDF))).fetch(); //pre-load
|
|
|
}
|
|
|
}
|