Giter VIP home page Giter VIP logo

mpmovieplayercontroller-subtitles's Introduction

Logo

issues โ€ƒ stars โ€ƒ license

MPMoviePlayerController-Subtitles is a library to display subtitles on iOS. It's built as a Swift extension and it's very easy to integrate.

How To Get Started

Installation with CocoaPods

platform :ios, '8.0'
pod "MPMoviePlayerController-Subtitles"

Manually installation

Download (right-click) and add to your project.

Requirements

Version Language Minimum iOS Target
2.2.x Swift 3.x iOS 8
2.0.x Swift 2.x iOS 8
1.x Objective-C iOS 6

Usage with player

import MPMoviePlayerControllerSubtitles
// Video file
let videoFile = Bundle.main.path(forResource: "trailer_720p", ofType: "mov")

// Subtitle file
let subtitleFile = Bundle.main.path(forResource: "trailer_720p", ofType: "srt")
let subtitleURL = URL(fileURLWithPath: subtitleFile!)

// Movie player
let moviePlayerView = MPMoviePlayerViewController(contentURL: URL(fileURLWithPath: videoFile!))
presentMoviePlayerViewControllerAnimated(moviePlayerView)

// Add subtitles
moviePlayerView?.moviePlayer.addSubtitles().open(file: subtitleURL)
moviePlayerView?.moviePlayer.addSubtitles().open(file: subtitleURL, encoding: String.Encoding.utf8)

// Change text properties
moviePlayerView?.moviePlayer.subtitleLabel?.textColor = UIColor.red

// Play
moviePlayerView?.moviePlayer.play()

Screenshot

Screenshoot

Usage without player

From version 2.2 you can search text in the SubRip file or text without need play any file.

import MPMoviePlayerControllerSubtitles
// Subtitle file
let subtitleFile = Bundle.main.path(forResource: "trailer_720p", ofType: "srt")
let subtitleURL = URL(fileURLWithPath: subtitleFile!)

// Subtitle parser
let parser = Subtitles(file: subtitleURL, encoding: .utf8)

// Do something with result
let subtitles = parser.searchSubtitles(at: 2.0) // Search subtitle at 2.0 seconds

Contact

License

Licensed under Apache License v2.0.
Copyright 2017 Marc Hervera.

mpmovieplayercontroller-subtitles's People

Contributors

mhergon avatar shafqat-muneer avatar bitdeli-chef avatar s424242 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.