Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP

Autres articles (61)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (7243)

  • NoMethodFoundException when trying to load native methods from jar file

    20 février 2018, par Anuran Barman

    I am trying to load ffmpeg methods in android. My requirement is that I dont want to pack the .so files within the apk.Only if the user wants then only I will download the jar file and load the ffmpeg native methods.After searching I think that loading .so files at run time is not possible.So what I did that I made the so file and created a different android application with only one class FFMPEG.java whose only duty is to call the native methods from ffmpeg library.so I made the jar file and loaded that into my main application with ClassLoader. Constructor is getting called so it means class is loaded but methods are not getting loaded though they are declared public in the jar file. I am trying to stream RTSP video with FFMPEG.Below are my jar file and main application codes.

    public class FFMPEG {

       public FFMPEG(){
           Log.d(FFMPEG.class.getSimpleName(),"constructor called");
       }

       public static native int naInit(String pFileName);
       public static native int[] naGetVideoRes();
       public static native void naSetSurface(Surface pSurface);
       public static native int naSetup(int pWidth, int pHeight);
       public static native void naPlay();
       public static native void naStop();

       public static boolean loadedLibraries;

       static {
           try {
               System.loadLibrary("avutil");
               System.loadLibrary("avcodec");
               System.loadLibrary("avformat");
               System.loadLibrary("swscale");
               System.loadLibrary("avfilter");
               System.loadLibrary("ffmpeg-jni");
               loadedLibraries = true;
           } catch (Throwable e) {
               e.printStackTrace();
           }
       }

       public int libInit(String filename){
           return  naInit(filename);
       }

       public int[] libGetVideoRes(){
           return  naGetVideoRes();
       }
       public void libSetSurface(Surface surface){
           naSetSurface(surface);
       }
       public int libSetup(int width,int height){
           return naSetup(width,height);
       }
       public void libPlay(){
           naPlay();
       }
       public void libStop(){
           naStop();
       }
    }

    My main application activity code.The jar file location in my sdcard named camlib.jar

    @SuppressWarnings("JniMissingFunction")
    public class MainActivity extends AppCompatActivity implements SurfaceHolder.Callback {

       private SurfaceView surfaceView;
       private ProgressBar progressBar;
       private final String TAG=MainActivity.class.getSimpleName();

       private boolean isPlaying;
       private boolean isClassLoaded;
       private boolean isInitialized;
       private String url="";
       Method libInit,libGetVideoRes,libSetSurface,libSetup,libPlay,libStop;
       Object myInstance;
       @Override
       protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
           setContentView(R.layout.activity_main);
           surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
           progressBar = ((ProgressBar) findViewById(R.id.progressBar));
           surfaceView.getHolder().addCallback(this);
           int permission= ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
           if(permission== PackageManager.PERMISSION_GRANTED){
               loadClass();
           }else{
               ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},200);
           }

       }

       @Override
       public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
           super.onRequestPermissionsResult(requestCode, permissions, grantResults);
           if(requestCode==200){
               if(grantResults.length>0){
                   if (grantResults[0]==PackageManager.PERMISSION_GRANTED){
                       loadClass();
                   }else{
                       ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},200);
                   }
               }
           }
       }

       public void loadClass(){
           try {
               final String libPath = Environment.getExternalStorageDirectory() + "/camlib.jar";
               final File tmpDir = getDir("dex", 0);

               final DexClassLoader classloader = new DexClassLoader(libPath, tmpDir.getAbsolutePath(), null, this.getClass().getClassLoader());
               final Class classToLoad = (Class) classloader.loadClass("com.myeglu.obbapplication.FFMPEG");

                myInstance  = classToLoad.newInstance();
                libInit= classToLoad.getMethod("libInit");
                libGetVideoRes=classToLoad.getMethod("libGetVideoRes");
                libSetSurface=classToLoad.getMethod("libSetSurface");
                libSetup=classToLoad.getMethod("libSetup");
                libPlay=classToLoad.getMethod("libPlay");
                libStop=classToLoad.getMethod("libStop");
                isClassLoaded=true;
                new PlayVideo().execute();

           } catch (Exception e) {
               e.printStackTrace();
           }
       }

       private void postInit() {
           if (isInitialized) {
               initPlay();
               progressBar.setVisibility(View.GONE);
           } else {
               finish();
           }
       }

       private void initPlay() {
           try {
               int[] res = (int[])libGetVideoRes.invoke(myInstance);
               Log.d("ANURAN", "res width " + res[0] + ": height " + res[1]);
               if (res[0] <= 0) {
                   res[0] = 480;
               }
               if (res[1] <= 0) {
                   res[1] = 320;
               }
               int[] screenRes = getScreenRes();
               int width, height;
               float widthScaledRatio = screenRes[0] * 1.0f / res[0];
               float heightScaledRatio = screenRes[1] * 1.0f / res[1];
               if (widthScaledRatio > heightScaledRatio) {
                   //use heightScaledRatio
                   width = (int) (res[0] * heightScaledRatio);
                   height = screenRes[1];
               } else {
                   //use widthScaledRatio
                   width = screenRes[0];
                   height = (int) (res[1] * widthScaledRatio);
               }
               Log.d(TAG, "width " + width + ",height:" + height);
               updateSurfaceView(width, height);
               libSetup.invoke(myInstance,width,height);
               playMedia();
           }catch (Exception e){

           }
       }

       private void playMedia() {
           try {
               if (progressBar.getVisibility() == View.VISIBLE) {
                   progressBar.setVisibility(View.GONE);
               }
               libPlay.invoke(myInstance);
               isPlaying = true;
           }catch (Exception e){

           }
       }
       private void updateSurfaceView(int pWidth, int pHeight) {
           //update surfaceview dimension, this will cause the native window to change
           Log.d("ANURAN UPDATE SURFACE", "width " + pWidth + ",height:" + pHeight);
           FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) surfaceView.getLayoutParams();
           params.width = pWidth;
           params.height = pHeight;
           surfaceView.setLayoutParams(params);
       }

       @SuppressLint("NewApi")
       private int[] getScreenRes() {
           int[] res = new int[2];
           Display display = getWindowManager().getDefaultDisplay();
           Point size = new Point();
           display.getSize(size);
           res[0] = size.x;
           res[1] = size.y;
           return res;
       }

       @Override
       protected void onStop() {
           super.onStop();
           Toast.makeText(MainActivity.this,"onStop called",Toast.LENGTH_SHORT).show();
           stopPlaying();
           finish();
       }

       @Override
       public void onBackPressed() {
           stopPlaying();
           finish();
       }

       private void stopPlaying() {
           isPlaying = false;
           try{
               libStop.invoke(myInstance);
           }catch (Exception e){

           }
       }

       @Override
       protected void onDestroy() {
           super.onDestroy();
           stopPlaying();
           finish();
       }



       @Override
       protected void onRestart() {
           super.onRestart();
           Toast.makeText(MainActivity.this,"onRestart called",Toast.LENGTH_SHORT).show();
           progressBar.setVisibility(View.VISIBLE);

       }


       @Override
       public void surfaceChanged(SurfaceHolder holder, int format, int width,
                                  int height) {

           if(isClassLoaded){
               try {
                   libSetSurface.invoke(myInstance,holder.getSurface());
               } catch (IllegalAccessException e) {
                   e.printStackTrace();
               } catch (InvocationTargetException e) {
                   e.printStackTrace();
               }
           }

       }

       @Override
       public void surfaceCreated(SurfaceHolder holder) {

       }

       @Override
       public void surfaceDestroyed(SurfaceHolder holder) {
           if(isClassLoaded) {
               try {
                   libSetSurface.invoke(myInstance, null);
               } catch (IllegalAccessException e) {
                   e.printStackTrace();
               } catch (InvocationTargetException e) {
                   e.printStackTrace();
               }
           }
       }



       private class PlayVideo extends AsyncTask {

           @Override
           protected Void doInBackground(Void... voids) {
               try {
                   int temp=(int)libInit.invoke(myInstance,url);
                   isInitialized=(temp==0);
               } catch (IllegalAccessException e) {
                   e.printStackTrace();
               } catch (InvocationTargetException e) {
                   e.printStackTrace();
               }
               return null;
           }

           @Override
           protected void onPostExecute(Void aVoid) {
               super.onPostExecute(aVoid);
               postInit();
               this.cancel(true);
           }
       }
    }
  • Evolution #2480 (Nouveau) : Pouvoir préparer la nouvelle version d’un article en ligne

    8 janvier 2012, par Stanislas _

    En mode par défaut, un article publié ne peut pas être modifié par son rédacteur. Seul un administrateur pourra effectuer une modification. Deux conséquences :

    un rédacteur ne peut pas proposer une nouvelle version d’un article publié de la même manière qu’il peut proposer un nouvel article

    toute (...)

  • Evolution #2211 : article à la poubelle -> forum toujours là

    15 août 2011, par cedric -

    Je ne sais pas si on doit considérer cela comme un bug. Ce comportement n’a pas changé depuis SPIP 2.1 au moins (et avant aussi il me semble que c’était déjà comme ça). On pourrait passer automatiquement tous les forums d’un article à la poubelle quand on supprime un article, mais cela perdrait des (...)