Giter Club home page Giter Club logo

cinemanaplayer's Introduction

Demo

Arabic subtitle ExoPlayer

Features

  • OkHttpDataSource
  • Subtitles (.srt files, e.g., Arabic subtitles)

    Setup

    Adding CinemanaPlayer Activity to your Manifest.xml

    <activity android:name="org.earthlink.cinemana.player.CinemanaVideoPlayer"
        android:configChanges="orientation|screenSize|keyboardHidden"
        />
    

    API

    Intent i = new Intent(this, CinemanaVideoPlayer.class);
    i.putExtra(CinemanaVideoPlayer.KEY_VIDEO_FILE, videoFile);
    i.putExtra(CinemanaVideoPlayer.KEY_START_POSITION, 0);
    
    startActivity(i);
    
    

    where:

  • **videoFile**: A data structure that has a `HashMap` containing a resolution and its url link.

    The VideoFile data structure is shown below:

        public static int QUALITY_720P = 3;
        public static int QUALITY_480P = 2;
        public static int QUALITY_360P = 1;
        public static int QUALITY_240P = 0;
    
        public static final int DASH = 0;
        public static final int SS = 1;
        public static final int HLS = 2;
        public static final int OTHER = 3;  // MP4 or WebM
    
    
        public int videoType = OTHER;
    
        public String title;
        public HashMap<Integer, String> resolutions = new HashMap<>();  // <quality, url>; e.g, <QUALITY_720P,     "http://example.com/video720p.mp4"
        public int selectedResolutioin;
    
        public String arTranslationFilePath;  // is the url link of the subtitle as an `srt` format.
    
    

    Subtitles

    Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP,
            null, Format.NO_VALUE, Format.NO_VALUE, "ar", null);
    
    
    MediaSource subtitleSource =
            new SingleSampleMediaSource(subtitleUri,
                    mediaDataSourceFactory, textFormat, C.TIME_UNSET);
    
    ExtractorMediaSource extractorMediaSource =
            new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
    

    The subtitles style can be configured from the library in the file CinemanaVideoPlayer.java:

        private void configureSubtitleView() {
            int defaultSubtitleColor = Color.argb(255, 218, 218, 218);
            int outlineColor = Color.argb(255, 43, 43, 43);
            Typeface subtitleTypeface = Typeface.createFromAsset(surfaceView.getContext().getAssets(), "fonts/Abdo-Line.otf");
            CaptionStyleCompat style =
                    new CaptionStyleCompat(defaultSubtitleColor,
                            Color.TRANSPARENT, Color.TRANSPARENT,
                            CaptionStyleCompat.EDGE_TYPE_OUTLINE,
                            outlineColor, subtitleTypeface);
    
            subtitleLayout.setStyle(style);
            subtitleLayout.setFractionalTextSize(SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION * fontScale);
        }
    
  • cinemanaplayer's People

    Contributors

    bluemix avatar

    Watchers

    James Cloos avatar

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.