Giter Club home page Giter Club logo

trvideoview's Introduction

TRVideoView

This is a simple drop in WKWebView for embedded videos from YouTube and vimeo.

Features

  • Provide a text and get back a WKWebView
  • Check if text has links
  • Return string without links
  • Resize WebView

screen shot 2017-09-21 at 1 47 28 pm

screen shot 2017-09-21 at 1 48 26 pm

Requierments

  • iOS 10.0
  • Swift 5.0
  • Xcode 11

Installation

CocoaPods

To integrate this into your Xcode project using CocoaPods, add it to your Podfile:

pod 'TRVideoView'

Then, run the following command:

$ pod install

Usage

// Initialize  
let video = TRVideoView(text: "This is some sample text with a YouTube link https://www.youtube.com/watch?v=QPAloq5MCUA")

// Or to play inline, initialize as
let video = TRVideoView(text: "This is some sample text with a YouTube link https://www.youtube.com/watch?v=QPAloq5MCUA", allowInlinePlayback: true)

// Set the frame as always, or use AutoLayout
video.frame = CGRect(x: 0, y: 0, width: 300, height: 150)

// Returns true or false (checks for YouTube and Vimeo urls)
video.containsURLs()

// Returns String with out URLs (i.e. "This is some sample text with a YouTube link")
let text = video.textWithoutURLs()

// Finally add it to your view
self.view.addSubview(video)

Notes on links

For YouTube either https://youtu.be/QPAloq5MCUA or https://www.youtube.com/watch?v=QPAloq5MCUA works.
For Vimeo use https://vimeo.com/86033976
If other parameters are also included in the link it does not matter, they are sorted out.

Contributing

Want to see other video services supported? You can open an issue and I will see what I can do.
If you would like to fork this project and add more features, go ahead and make a PR, I'm happy about your contributions.

trvideoview's People

Contributors

timroesner avatar zackdotcomputer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

trvideoview's Issues

custom play button

Hello there,

First please forgive my ignorance, however I implemented TRVideoView in my project and what I do is I created a thumbnail view which covers the TRVideoView and inside that thumbnail view I added a custom button, the current behaviour im looking for, is when a user clicks that custom button, I hide the thumbnail view and start the video

any idea how to do that ?

currently inside the TRVideoView.swift file, iframeForLink function, I added a function called clickVideo

internal func iframeForLink(_ link: String) -> String {
return "<head> <meta name=viewport content='width=device-width, initial-scale=1'><style type='text/css'> body { margin: 0;} </style></head><iframe id=\"video1\" src='\(link)' width='100%' height='100%' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe><script>function clickVideo(){ document.getElementById(\"video1\").src += \"&autoplay=1\"}</script>"
}

I call it by calling the following code
let _ = webView.evaluateJavaScript("clickVideo()", completionHandler: nil)
where webView is the TRVideoView

It's not working though, any help ?

Thank you so much in advance

Videos always takes over full screen to play

Really like the library and it solves exactly the issue I was having (especially since Google's own library appears to be abandoned). My main question/issue/feature-request is:

  • On iOS 13 on an iPhone 11, videos load fine but always default to full screen to play back.
  • I know that it's possible to play inline, but don't see any parameters in your wrapper class to specify "don't default to full screen"
    My question, then, is:
  • Is this ability implemented but not documented, is this possible and I should write it and PR it, or is this not possible given how this library is implemented?

Player not working

I checked recently TRVideoView not working with youtube url (Url play on web) even i have copied url from web and pass directly but didn't work.
[https://www.youtube.com/watch?v=2DDk-1aLnm4&feature=youtu.be]
No error log .

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.