I'm using YTPlayerView (YouTube helper library) in my iOS application and according to requirements, I've made custom controls for airplay, share, play etc. For that I've hidden the default controls of YTPlayer using "control" tag.
The problem I'm facing is that, when I play video via airplay on some other media (e.g. appleTV, air server), the default view of YTPlayerView saying "Streaming to ... " Doesn't appear.
I guess it's because I've hidden the default controls.
I want this view to appear on screen whenever user choose other route for video. Unfortunately I'm unable to find the solution. Is there any way to do this or any notification that's fired whenever user switches video route, so that I can place my custom view for that scenario.
Related
I have created instance of AVPlayer and playing content in it. I need to provide one option to show this movie in full screen. Does any other option present instead of creating instance of AVPlayerController and using native playback button options.
AVPlayer is containing only video view. Buttons and basically all the UI over the video are responsibility of developer.
So you need to do view controller that have view where AVPLayer will be embedded, and over it another views (like buttons, labels). And of course rig everything with constraints. When you tap "full screen" button, animate constraints so you resize your video. This is it.
Much simpler (considering lines of code that must be written) is to use AVPLayerViewController, but you loose possibility of custom UI. On other hand most of the logic is there. (except for support HLS EVENT type playlists that are not closed, there is a bug that will be fixed in iOS11)
Update:
Bug in AVPLayerViewController, regarding HLS EVENT type is fixed in iOS11.
Web View - Playback Requires User Action - in Swift
Hi there.
In my Main Storyboard I have a Web View, that is triggered by a button.
When the button is pressed, it pops up a music video from Youtube. When I then press the “Play-button” in this Youtube view, the song is played, meaning I have visuals and audio :-)
Under the Web View Options, there is a checkbox called "Playback Requires User Action”.In the help explanation it says:
“mediaPlaybackRequiresUserAction
Property
A Boolean value that determines whether HTML5 videos can play automatically or require the user to start playing them.
Declaration
SWIFT
var mediaPlaybackRequiresUserAction: Bool
Discussion
The default value on both iPad and iPhone is YES. To make media play automatically when loaded, set this property to NO and ensure the or element you want to play has the autoplay attribute set.”
What does "autoplay attribute set” mean ?
I want this music video played, without pressing the “Play-button” in the Youtube view ? Is this even possible ?
Have searched, but found nothing.
I'm a novice and can’t figure out, how to do this.
Does anyone have a clue ? :-)
It would be highly appreciated.
Ola
I have a requirement to create custom controls for Youtube player in iOS. I have used UIWebview to play youtube videos. I have hidden default controls by using 'controls':0 flag. I am able to map all the actions like play, pause etc using youtube's java script api with my UIButtons. But, I am not able to figure out how to toggle full screen mode programatically with my custom button.
Any help is appreciated.
I'm developing an iOS iPad app with an embedded YouTube video.
I'm having issues when the user tries to play the video touching the red square play image from YouTube, it seems that pressing that image won't trigger the play action. However, touching anywhere outside the red square play button works.
I've tested it with the iPad user agent with same results.
When embedding with controls:0 it seems that the action triggers perfectly, but I need the default controls.
Is there anyway to keep controls:1 and detect that touch to successfully play the video?
Try playing the video itself when it is loaded. If hitting the big red button is not a compulsion add "event.target.playVideo();" to the onReady function in the embeded HTML body. I have done so and the player in my application shows the big red button and starts the video itself immediately. I have used the following YouTube iFrame library youtube-ios-player-helper
I have an iPad app and I have a video playing in a view. I would like to play video using Airplay but by pressing my own button.
I have set allows airplay = YES and so forth, this works if I enable the full controls, but I want to set no controls and have my own button to play the video using Airplay.
So far, I have found no information that would allow me to play a video on AppleTV without allowing the normal controls.
So just using an UIButton action to force the airplay, or at least get available devices and set it manually. Anything that would allow me to do this.
MPVolumeView will only control audio, it won't control video. For that you'd need iOS 5's AVPlayer, or a movie controller.
An alternative for you might be to use AirplayKit, a 3rd party library.
https://github.com/rothacr/AirplayKit
To answer my own question.
This is quite possible without jailbreak.
Here is apple's own page explaining this, so this will pass the review process.
Apple developer library document explaining how to do this