millmany / mmplayerview Goto Github PK
View Code? Open in Web Editor NEWCustom AVPlayerLayer on view and transition player with good effect like youtube and facebook
License: MIT License
Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook
License: MIT License
I have an issue with that.
I have a tabbar with three tabbar items. just call it is A B C
In A viewcontroller I extension MMPlayerFromProtocol
In B viewcontroller I extension MMPlayerFromProtocol
then in viewcontroller B I try to pass Player to another viewController but MMPlayerFromProtocol raised in A
Can you explain why?
Thank you so much.
Hi am also using the same way to Play Video in Collection View. There is a list of images and videos showing in collection view.
[ Video type ]
[ Image type ]
[ Video type ]
[ Video type ]
[ Video type ]
[ Image type ]
[ Image type ]
fileprivate func updateCell(at indexPath: IndexPath) {
if let cell = self.collectionView!.cellForItem(at: indexPath) as? TimelineFeedCell {
// this thumb use when transition start and your video dosent start
let postDict = self.arrayPostData[indexPath.item]
print(indexPath.item)
if postDict.video_flag == 0 {
mmPlayerLayer.playView = nil
mmPlayerLayer.player?.pause()
mmPlayerLayer.playUrl = nil
} else {
mmPlayerLayer.thumbImageView.image = cell.postImageView.image
// set video where to play
if !MMLandscapeWindow.shared.isKeyWindow {
mmPlayerLayer.playView = cell.postImageView
}
// set url prepare to load
mmPlayerLayer.set(url: URL(string: cell.postModelInfo?.image_url ?? ""), state: { (status) in
switch status {
case .failed(let err):
print("err", err)
case .ready:
print("Ready to Play")
case .playing:
print("Playing")
case .pause:
print("Pause")
case .end:
print("End")
default: break
}
})
}
}
}
Am using your function but Still am not able to stop the previous cell of video. Video is still playing but my current cell is of image. How can I resolve this issue. Please Help me
Is there a configuration to loop video playback?
Hey @MillmanY , when I pushing the view controller to another view controller, how can I pass the mmplayerView values to another controller so that same video will play to detail Screen. You have provide the example of present. How can we achieve using push or Segue
Hi, I put a button to covera cell. When I click button video will be play in fullscreen view
How can I do this ? Any help ?
what I did in CoverA cell
@IBAction func btnFullAction(_ sender: Any) {
let full = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FullScreenViewController") as! FullScreenViewController
MMLandscapeWindow.shared.makeKey(root: full, playLayer: self.playLayer!, completed: {
print("landscape completed")
//self.playerCollect.isScrollEnabled = true
})
}
Video does not fit in the container view it gets cropped either by width or by height.
I want to play video as its captured resolution is.
How can I play MMPlayerview with the Specific seek time? I'm playing video in the TableViewcell I need to have videos play where they are paused while scrolling. So I'm asking where can I do that in the code?
hi thanks for this library.
My question is when i click the 2. row in collection view, 1. row is starting to play.
How can I solve this ?
I have used MMPlayerLayer in tableview cell
mmPlayerLayer.playView = cell.imgView
mmPlayerLayer.set(url: cell.data?.play_Url, state: { (status) in
})
mmPlayerLayer.startLoading()
Like
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let resource = Bundle.main.path(forResource: "video", ofType: "mp4") else {
print("VIDEO ERROR")
return
}
//
let url = URL.init(fileURLWithPath: resource)
let cell = self.tableView.cellForRow(at: indexPath) as! VideoCell
mmPlayerLayer.playView = cell.imgView
mmPlayerLayer.set(url: url, state: { (status) in
})
mmPlayerLayer.startLoading()
}
on scrolling its showing on other cell too. what am i doing wrong?
in my app there is a play button. When i click play button mmplayerview.startloadinf fund calling and later i hide play button.
My question is when i click different cell only thumb image is show on before cell.
How can i handle this ?
func playButtonDelegate(at index: IndexPath) {
if let jlist = self.joinAllAllowedInnoList, !jlist.isEmpty {
self.mmPlayerLayer.startLoading()
if let videoKey = jlist[index.row].teaserVideo , !videoKey.isEmpty{
let cell = joinTableView.cellForRow(at: index) as! JoinCell
self.getVideoUrl(videoKey: videoKey) { videoURL in
cell.playButton.isHidden = false
self.mmPlayerLayer.thumbImageView.image = cell.thubnailImageView.image
//set video where to play
if !MMLandscapeWindow.shared.isKeyWindow {
self.mmPlayerLayer.playView = cell.thubnailImageView
}
//set url prepare to load
let url = URL(string: videoURL)
jlist.forEach { $0.isPlaying = false }
cell.titleView.isHidden = true
self.mmPlayerLayer.set(url: url, state: { (status) in
switch status {
case .failed(let err):
let alert = UIAlertController(title: "err", message: err.description, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
jlist[index.row].isPlaying = false
break
case .ready:
print("Ready to Play")
break
case .playing:
print("Playing")
jlist[index.row].isPlaying = true
//cell.playButton.isHidden = jlist[index.row].isPlaying
break
case .pause,.end:
print("End")
jlist[index.row].isPlaying = false
//cell.playButton.isHidden = jlist [index.row].isPlaying
break
default: break
}
})
self.mmPlayerLayer.startLoading()
}
}
}
}
The Video is playing as it needs to but the issue is that when the device is in silent mode then the audio is not playing at all. I think that this issue is pointed here URL or maybe not.
I use example MMPlayerView. I have didSelectRowAt indexPath
, but this don't work. Before MMPlayerView didSelectRowAt indexPath
worked. For show video I use @IBOutlet weak var imgVideo: UIImageView!
in class UITableViewCell
then I tried did next:
let tapVideoImgGesture = UITapGestureRecognizer(target: self, action: #selector(tapOnVideoImg(tapGestureRecognizer:))) imgVideo.isUserInteractionEnabled = true imgVideo.addGestureRecognizer(tapVideoImgGesture)
@objc func tapOnVideoImg(tapGestureRecognizer: UITapGestureRecognizer){ print("tap video image") }
the above code does not work
How to stop play video?
For example, in collectionView list there are also image types?
Like this:
[ Video type ]
[ Image type ]
[ Video type ]
[ Video type ]
[ Video type ]
[ Image type ]
[ Image type ]
Hello,
I'm using MMPlayerView to play video url , video is playing fine but sound not working ,not able to hear sounds so what should I do to get sound in device.
Thanks a lot for the great library.
can you please provide code or example for push transition?
I'm using MMplayerLayer for viewing images in table view, But it won't stop even after pushing new controller. How can I make it stop from playing if pushing new Controller.
Hi there dear sir,
I have an app which is similar to utube.
I want player to play after you present a viewcontroller, and when i rotate full screen, first time it works, after that the full screen doesnt work when i close the presented viewcontroller and open another one, doesnt update the latest video.
How do i approach this?
Here is the code i use on detail page:
let playerController = storyboard?.instantiateViewController(withIdentifier: "GVPlayerController") as! GVPlayerController
playerController.videoObjectBasic = videoBasic
//self.navigationController?.pushViewController(playerController, animated: false)
self.present(playerController, animated: true)
var videoObjectBasic: GVVideoBasic?
lazy var mmPlayerLayer: MMPlayerLayer = {
let l = MMPlayerLayer()
l.cacheType = .memory(count: 5)
l.coverFitType = .fitToPlayerView
l.videoGravity = AVLayerVideoGravity.resizeAspect
l.replace(cover: GVPlayerView.instantiateFromNib())
return l
}()
@IBOutlet var playerContainer: UIView!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
NotificationCenter.default.addObserver(forName: .UIDeviceOrientationDidChange, object: nil, queue: nil) { [unowned self] (_) in
self.landscapeAction()
}
}
fileprivate func landscapeAction() {
if UIDevice.current.orientation.isLandscape {
let full = self.storyboard?.instantiateViewController(withIdentifier: "GVFullScreenPlayerController") as! GVFullScreenPlayerController
MMLandscapeWindow.shared.makeKey(root: full, playLayer: mmPlayerLayer, completed: {
print("landscape completed")
// self.playerCollect.isScrollEnabled = true
})
}
}
if !MMLandscapeWindow.shared.isKeyWindow {
self.mmPlayerLayer.playView = self.playerContainer
}
self.mmPlayerLayer.set(url: URL.init(string:urlString)!, state: { (status) in
switch status {
case .failed(let err):
let alert = UIAlertController(title: "err", message: err.description, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
case .ready:
print("Ready to Play")
case .playing:
print("Playing")
case .pause:
print("Pause")
case .end:
print("End")
default: break
}
})
self.mmPlayerLayer.startLoading()
}
Basically it doesn't change or load, second video when first video is dismissed.
What im doing wrong ?
Thank you for your time
Hello,
I have arranged a controller where I select a certain video and then I pass the correct index path to play it.
Everything is fine but when I go to landscape and then go back to the first controller and select a different video, it correctly plays in portrait, but when I switch again to landscape, the extension shows the previous video (the very first one). When I switch back to portrait I see the correct one (like second or third video selected).
It clearly is something related to the previous index not being released in the landscape controller. And I am sure it is MY fault.
But eventually you can help me figure out where I can/I am supposed to release that information... Thanks so much!
Cristiano
I've tried several ways of installing the pod file but keeps giving me the following errors:
[!] Unable to find a specification for MMPlayerView (~> 3.0.2)
[!] Unable to find a specification for MMPlayerView (= 3.0.2)
[!] Unable to find a specification for MMPlayerView
note: I was trying to install them individually, not all together as it shows above.
After navigating back from detail view controller, main collection view doesn't show the video view.
Hi, firstly thanks for this awesome library.
My question is I added a pull screen button to CoverA.xib and set action.
What should i write in my custom full screen button action ? THANKS. :)
How to play video in collectionview inside of table view like instagram ?
How to control volume for the video Like Instagram
2018-06-20 04:29:56.518423+0530 Surface[16673:3477699] CredStore - performQuery - Error copying matching creds. Error=-25300, query={
class = inet;
"m_Limit" = "m_LimitAll";
"r_Attributes" = 1;
sync = syna;
}
Whenever I play a video I got this in my log.
Hi,
I was wondering if there is a way to make video play from starting even if it is cached in memory,
so that it will start playing faster since its cached.
Hi, I added a custom label in coverA cell.
My question is how can i set this label in my tableview cellForRowAt ?
thanks so much :)
Hello,
I am trying to play a video in other viewcontroller not in UICollectionview by this method.
func playVideo(urlStr: String){
self.playerLayer?.stopLoading()
if !MMLandscapeWindow.shared.isKeyWindow{
mmPlayerLayer.playView = self.ivScoop
}
// set url prepare to load
mmPlayerLayer.set(url: URL(string: (Constant.URL_VIDEO_SCOOP_END_POINT + urlStr)), state: { (status) in
switch status{
case .ready:
print("ready to play")
case .unknown:
print("unknown")
case .failed(let err):
print("eroror")
case .playing:
print("playing")
case .pause:
print("pause")
case .end:
break
}
})
}
But it's not working. and status is just unknow .
Please help me.
Thank you very much.
How to play video for uitableview inside collection view like instagram ?
Hello,
I want to remove custom transition to other viewcontroller that I don't want pass the video.
Because now if I don't implement PassViewToProtocol in other viewcontroller I get frozen. how can I fix that issue.
Thank you so much.
Hi @MillmanY I am a graphics designer and i would like do contribute to your nice project by designing a logo for it as a gift for free. If you will permit me i will begin immediately.. Best regards!
Hello,
When the video ready to play I always get the blank black color before play video. Can you let me know why.
Thank you so much.
Change the background Of AvPlayer.
Stored value type does not match pointer operand type!
store i64 %1, i32* %14, align 4, !dbg !3254
i32Stored value type does not match pointer operand type!
store i64 %2, i32* %17, align 4, !dbg !3254
i32Stored value type does not match pointer operand type!
store %swift.refcounted* %3, i64* %19, align 4, !dbg !3254
i64:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
:0: note: Broken function found, compilation aborted!
0 swift 0x000000010e0badba PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010e0ba1f6 SignalHandler(int) + 662
2 libsystem_platform.dylib 0x00007fffd6aabb3a _sigtramp + 26
3 libsystem_platform.dylib 0x000000010f865551 _sigtramp + 953915953
4 libsystem_c.dylib 0x00007fffd6930420 abort + 129
5 swift 0x000000010aa29fe7 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_0::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, bool) + 551
6 swift 0x000000010e0783fb llvm::report_fatal_error(llvm::Twine const&, bool) + 571
7 swift 0x000000010e0781ba llvm::report_fatal_error(char const*, bool) + 42
8 swift 0x000000010e04e6b6 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) + 54
9 swift 0x000000010dffbaaa llvm::FPPassManager::runOnFunction(llvm::Function&) + 506
10 swift 0x000000010e003609 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 377
11 swift 0x000000010e0033fa llvm::legacy::FunctionPassManager::run(llvm::Function&) + 410
12 swift 0x000000010aba3778 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex, llvm::GlobalVariable, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 5016
13 swift 0x000000010aa2ec18 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 19496
14 swift 0x000000010aa28784 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
15 swift 0x000000010a9dd6a8 main + 12248
16 libdyld.dylib 0x00007fffd689c235 start + 1
Stack dump:
Hello.
The video is loading then I want to stop loading but seems it's don't work. I already call stopLoading() but when the video was loaded it will be playing.
ViewController
CollectionView
CollectionViewCell
Play full screen video mode from collectionViewCell then pop this viewcontroller, I noted this viewcontroller doesn't deinit called.
But if I don't select full screen from collectionview then pop this viewcontroller will raise the deinit function.
Can you check.
Hello Sir.
Thank your for library.
I have an issue , for now I still don't know how to control that. I want to resume video immediately when scroll down or scroll up. (like Facebook) (apply this for the video already playing then pause state).
I have just try to put MMPlayerLayer in each cell then when cell is invisible I set it's pause then play it again when that cell visible but really laggy.
In this library seems to cache the last time of video then init and play with that time. but in this way I need to wait indicator loading.
One more thing. I really want to keep the last thumb when the video pause.
Can you help me.
Thank you so much.
hi,
How do I get my MMPlayerView to play while app is in background?
Hi,
Thank you very much for your work. How can I set mmplayer to fullscreen?
I've been tying to find a way to reset and restart a video form URL after it encounters an error for the past 3 days... Anyone have a suggestion on how to do it?
when video is loading from url and dismiss view controller but after some time video is play in background. how to fixed is this.
Can I change video url and video, while i am in full screen, basically if i have autoplay and i am in full screen to go from one video in next without the need to leave full screen?
Thank you @MillmanY
Hi, I want to put a view in cover a cell. In this view, I wan to put a label.
My aim is this label will be my video name.
My question is how can i set video name dynamically using coverA cell ? thanks.
I am Using Player in tableViewCell when next video is playing then previous Video thumb is shown in Player. can you suggest any solution or improve in library.
Installing MMPlayerView (3.0.10)
[!] Error installing MMPlayerView
[!] /usr/bin/git clone https://github.com/MillmanY/MMPlayerView.git /var/folders/pr/fhmj14x91td_543s8_cg5b3r0000gn/T/d20180228-8288-1j7qrfg --template= --single-branch --depth 1 --branch 3.0.10
Cloning into '/var/folders/pr/fhmj14x91td_543s8_cg5b3r0000gn/T/d20180228-8288-1j7qrfg'...
warning: Could not find remote branch 3.0.10 to clone.
fatal: Remote branch 3.0.10 not found in upstream origin
Is there a completion or something like this for startLoading()
?
I have a collectionView. In cell there is a video. When cell is dequeuing the video starts loading. autoPlay is false. I want to manually start the video after it get loaded. How can i achieve that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.