Class ShadowMediaMetadataRetriever


  • @Implements(android.media.MediaMetadataRetriever.class)
    public class ShadowMediaMetadataRetriever
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void addException​(DataSource ds, java.lang.RuntimeException e)
      Configures an exception to be thrown when setDataSource(org.robolectric.shadows.util.DataSource) is called for the given data source.
      static void addFrame​(android.content.Context context, android.net.Uri uri, long time, android.graphics.Bitmap bitmap)
      Adds the given bitmap at the given time for the given data source.
      static void addFrame​(java.io.FileDescriptor fd, long offset, long length, long time, android.graphics.Bitmap bitmap)
      Adds the given bitmap at the given time for the given data source.
      static void addFrame​(java.io.FileDescriptor fd, long time, android.graphics.Bitmap bitmap)
      Adds the given bitmap at the given time for the given data source.
      static void addFrame​(java.lang.String path, long time, android.graphics.Bitmap bitmap)
      Adds the given bitmap at the given time for the given data source.
      static void addFrame​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.String> headers, long time, android.graphics.Bitmap bitmap)
      Adds the given bitmap at the given time for the given data source.
      static void addFrame​(DataSource ds, long time, android.graphics.Bitmap bitmap)  
      static void addMetadata​(java.lang.String path, int keyCode, java.lang.String value)
      Adds the given keyCode/value pair for the given data source.
      static void addMetadata​(DataSource ds, int keyCode, java.lang.String value)  
      static void addScaledFrame​(DataSource ds, long time, int dstWidth, int dstHeight, android.graphics.Bitmap bitmap)  
      protected java.lang.String extractMetadata​(int keyCode)  
      protected android.graphics.Bitmap getFrameAtTime​(long timeUs, int option)  
      protected android.graphics.Bitmap getScaledFrameAtTime​(long timeUs, int option, int dstWidth, int dstHeight)  
      static void reset()  
      protected void setDataSource​(android.content.Context context, android.net.Uri uri)  
      protected void setDataSource​(android.media.MediaDataSource mediaDataSource)  
      protected void setDataSource​(java.io.FileDescriptor fd, long offset, long length)  
      protected void setDataSource​(java.lang.String path)  
      protected void setDataSource​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.String> headers)  
      void setDataSource​(DataSource dataSource)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowMediaMetadataRetriever

        public ShadowMediaMetadataRetriever()
    • Method Detail

      • setDataSource

        public void setDataSource​(DataSource dataSource)
      • setDataSource

        @Implementation
        protected void setDataSource​(java.lang.String path)
      • setDataSource

        @Implementation
        protected void setDataSource​(android.content.Context context,
                                     android.net.Uri uri)
      • setDataSource

        @Implementation
        protected void setDataSource​(java.lang.String uri,
                                     java.util.Map<java.lang.String,​java.lang.String> headers)
      • setDataSource

        @Implementation
        protected void setDataSource​(java.io.FileDescriptor fd,
                                     long offset,
                                     long length)
      • setDataSource

        @Implementation(minSdk=23)
        protected void setDataSource​(android.media.MediaDataSource mediaDataSource)
      • extractMetadata

        @Implementation
        protected java.lang.String extractMetadata​(int keyCode)
      • getFrameAtTime

        @Implementation
        protected android.graphics.Bitmap getFrameAtTime​(long timeUs,
                                                         int option)
      • getScaledFrameAtTime

        @Implementation(minSdk=27)
        protected android.graphics.Bitmap getScaledFrameAtTime​(long timeUs,
                                                               int option,
                                                               int dstWidth,
                                                               int dstHeight)
      • addException

        public static void addException​(DataSource ds,
                                        java.lang.RuntimeException e)
        Configures an exception to be thrown when setDataSource(org.robolectric.shadows.util.DataSource) is called for the given data source.
        Parameters:
        ds - the data source that will trigger an exception
        e - the exception to trigger, or null to avoid throwing an exception.
      • addMetadata

        public static void addMetadata​(DataSource ds,
                                       int keyCode,
                                       java.lang.String value)
      • addMetadata

        public static void addMetadata​(java.lang.String path,
                                       int keyCode,
                                       java.lang.String value)
        Adds the given keyCode/value pair for the given data source. Uses path to call DataSource.toDataSource(String) and then calls addMetadata(DataSource, int, String). This method is retained mostly for backwards compatibility; you can call addMetadata(DataSource, int, String) directly.
        Parameters:
        path - the path to the data source whose metadata is being set.
        keyCode - the keyCode for the metadata being set, as used by MediaMetadataRetriever.extractMetadata(int).
        value - the value for the specified metadata.
      • addFrame

        public static void addFrame​(DataSource ds,
                                    long time,
                                    android.graphics.Bitmap bitmap)
      • addScaledFrame

        public static void addScaledFrame​(DataSource ds,
                                          long time,
                                          int dstWidth,
                                          int dstHeight,
                                          android.graphics.Bitmap bitmap)
      • addFrame

        public static void addFrame​(java.lang.String path,
                                    long time,
                                    android.graphics.Bitmap bitmap)
        Adds the given bitmap at the given time for the given data source. Uses path to call DataSource.toDataSource(String) and then calls addFrame(DataSource, long, Bitmap). This method is retained mostly for backwards compatibility; you can call addFrame(DataSource, long, Bitmap) directly.
        Parameters:
        path - the path to the data source.
        time - the playback time at which the specified bitmap should be retrieved.
        bitmap - the bitmap to retrieve.
      • addFrame

        public static void addFrame​(android.content.Context context,
                                    android.net.Uri uri,
                                    long time,
                                    android.graphics.Bitmap bitmap)
        Adds the given bitmap at the given time for the given data source. Uses path to call DataSource.toDataSource(Context, Uri) and then calls addFrame(DataSource, long, Bitmap). This method is retained mostly for backwards compatibility; you can call addFrame(DataSource, long, Bitmap) directly.
        Parameters:
        context - the Context object to match on the data source.
        uri - the Uri of the data source.
        time - the playback time at which the specified bitmap should be retrieved.
        bitmap - the bitmap to retrieve.
      • addFrame

        public static void addFrame​(java.lang.String uri,
                                    java.util.Map<java.lang.String,​java.lang.String> headers,
                                    long time,
                                    android.graphics.Bitmap bitmap)
        Adds the given bitmap at the given time for the given data source. Uses path to call DataSource.toDataSource(String, Map) and then calls addFrame(DataSource, long, Bitmap). This method is retained mostly for backwards compatibility; you can call addFrame(DataSource, long, Bitmap) directly.
        Parameters:
        uri - the Uri of the data source.
        headers - the headers to use when requesting the specified uri.
        time - the playback time at which the specified bitmap should be retrieved.
        bitmap - the bitmap to retrieve.
      • addFrame

        public static void addFrame​(java.io.FileDescriptor fd,
                                    long time,
                                    android.graphics.Bitmap bitmap)
        Adds the given bitmap at the given time for the given data source. Uses path to call DataSource.toDataSource(FileDescriptor) and then calls addFrame(DataSource, long, Bitmap). This method is retained mostly for backwards compatibility; you can call addFrame(DataSource, long, Bitmap) directly.
        Parameters:
        fd - file descriptor of the data source.
        time - the playback time at which the specified bitmap should be retrieved.
        bitmap - the bitmap to retrieve.
      • addFrame

        public static void addFrame​(java.io.FileDescriptor fd,
                                    long offset,
                                    long length,
                                    long time,
                                    android.graphics.Bitmap bitmap)
        Adds the given bitmap at the given time for the given data source. Uses path to call DataSource.toDataSource(FileDescriptor, long, long) and then calls addFrame(DataSource, long, Bitmap). This method is retained mostly for backwards compatibility; you can call addFrame(DataSource, long, Bitmap) directly.
        Parameters:
        fd - file descriptor of the data source.
        offset - the byte offset within the specified file from which to start reading the data.
        length - the number of bytes to read from the file.
        time - the playback time at which the specified bitmap should be retrieved.
        bitmap - the bitmap to retrieve.
      • reset

        @Resetter
        public static void reset()