I want to play YouTube video in specific view size. currently I'm unable to play video in full view size.
You can check the below image where black part is displaying in both left and right side.
First of all, you should set your custom YTPlayerView with content mode equal to "scale to fill". Next, you should set the playsinline property to 0.
Here below I show you a little example:
var playerVars:Dictionary =
["playsinline":"0", // 1 in view or 0 fullscreen
"autoplay":"1", // Auto-play the video on load
"modestbranding":"1", // without button of youtube and giat branding
"rel":"0",
"controls":"0", // Show pause/play buttons in player
"fs":"1", // Hide the full screen button
"origin":"https://www.example.com",
"cc_load_policy":"0", // Hide closed captions
"iv_load_policy":"3", // Hide the Video Annotations
"loop":"0",
"version":"3",
"playlist":"",
"autohide":"0", // Hide video controls when playing
"showinfo":"0"] // show related videos at the end
self.playerView.load(withVideoId: videoId, playerVars: playerVars)
Remember if you want a good resolution inside your view using a 16:9 view when you try to play a 4:3 video you have always black side parts and this behaviour is correct and reasonable.
If you want more specific details about your request you can find interesting information in this page (a page related to the official gitHub Youtube sources)
Related
In iOS 16, Lock screen widgets allow you to add an Image to the WidgetView, like in accessoryCircular.
How do you animate this Image? Loading the Image from an animated UIImage with frames just displays the first frame.
Am I missing a startAnimating call, like you have to do with WKInterfaceObjects? Is there some additional step or value to set to get an Image inside a SwiftUI WidgetView to begin animating, or cycling through frames?
Examples of apps that have achieved this are https://www.livelywidget.com or Pixel Pal, so I know it's possible, but when I search for APIs to accomplish this, all that comes up are apps.
Ok. Here is the question. I have tabBar controller, in tab at index 0 I have a TableView with cells showing video by AVPlayerViewController. For iPhone, when i print content of UIApplication.shared.windows - it has only 2 window - UIWindow and UITextEffectWindow. But for iPad - it has UIWindow, UITextEffectWindow and several PGHostedWindow (3-4 depends on the number of cells with video).
What are those PGHostedWindows? It seems to me that they are creating along with AVPlayer when it's view is added to cell's view hierarcy - and it led me to the thought that it may be connected with iPad's ability to show video in "Picture in picture" mode. But even if I set AVPlayerViewController's allowsPictureInPicture to false - those windows are still creating. And the worst part - even if I scroll those cells with video from visible area,or go to another tab - those PGHostedWindows are not deallocated.
So the question is - what are those PGHostedWindows/ and how to prevent their creating?
I was trying to debug an AVKit issue with restoring from picture in picture and also noticed and wondered about PGHostedWindow. Like another commenter said, I don't see a reason for concern about its creation or lifetime. My understanding is AVPlayer moves the AVPlayerLayer between windows when moving in/out of PiP, and this window is one that the system manages.
Of note, which led me here: I noticed there is a longstanding issue where any subviews on AVPlayerLayer get clipped by the video after the view gets reinstalled on PiP. Apple's sample code has the same issue if the controls are extended. So maybe there's a few issues with PGHostedWindow, but we're stuck with them.
I'm trying to get my QBRTCRemoteVideoView to present a full-screen video output, similar to FaceTime or Skype.
However, using AutoLayout in my project, and setting the constraints to lead and trail to the superview, the video I get back does not follow those constraints. It shows with black borders on the top and bottom.
Even using the following properties:
videoFormat.width = 320; // or anything
videoFormat.height = 568; // or anything
Does not seem to change the dimensions of the video. Any advice for me here on controlling the video output view?
You can only set a specific width and height for video, to see what kind of video formats are supported by your device, call:
[QBRTCCameraCapture formatsWithPosition:AVCaptureDevicePositionFront];
// or AVCaptureDevicePositionBack
// or just get the currentPosition from your QBRTCCameraCapture instance
I have a high(er) resolution (500 x 403) "video intro" that a client wants me to add to the beginning of a "main" video they delivered to me. The main video is low res (200 x 150).
I can EITHER makes the intro low res and add it (which the client doesn't like) OR I can double the resolution of the main video and add it (which balloons the bandwidth required to download and play the movie.) Also not optimal as this is destined for mobile.
I have a third solution I am going to use. I am playing the high res "intro video" and when that ends I am automatically loading the main video and playing it right behind the intro by creating a playlist containing the intro and the main video.
The problem I have is the default controller behavior for HTML 5 video is to be visible for the first 2 or 3 seconds of a video and then fade out. This is fine for the first video in the playlist however I would like the control to not show at the beginning of subsequent videos. The intro is only 6 seconds and the appearing and disappearing controls look messy and I would like both videos to appear as one.
I have tried using "videoPlayer.removeAttribute("controls");" however this kills the controls entirely so if a user taps the video later to intentionally bring the controls back up later nothing happens. Ideally I would like to keep all the default behavior with the exception of showing the controls at the beginning of the video.
I have seen some long winded attempts at trying to modify video.js to achieve something of this nature but ideally I can do something to the native features to enable this.
Any ideas?
Original code:
<script type="text/javascript">
$(document).ready(function(){
var xx=1;
var nextVideo = new Array();
nextVideo[0] = "Content/videos/Logo_Animate_537.mp4";
nextVideo[1] = "Content/videos/Main.mp4";
nextVideo[2] = "Content/videos/Logo_Animate_537.mp4";
$("#videoPlayer").bind('ended', function(){
if(xx>nextVideo.length-1){
videoPlayer.setAttribute("controls","controls");
videoPlayer.pause();
xx=1;
} else {
videoPlayer.removeAttribute("controls");
videoPlayer.src = nextVideo[xx];
videoPlayer.play();
xx++;
}
});
//+++++++++++++++++++ This section was added as the solution ++++++++++++++
$("#videoPlayer").on('click touchstart', function () {
videoPlayer.setAttribute("controls","controls");
});
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
});
</script>
<video id="videoPlayer" width="537" height="403" controls poster="images/main.jpg">
<source src="Content/videos/Logo_Animate_537.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
It seems like you have two options here. The first one is to simply remove and replace the controls attribute as you need. This would be the simplest solution, as
element.setAttribute('controls', '')
will simply put the controls back when you need them. The other option is to not use the browser controls at all, define your own custom controls, and hide or show them as you wish.
If a YouTube video is embed in a web page is there a way to have a small size (example 200 x 150) then have it re-size larger (example 400 x 300) when it is played. An example would be when a video is received in Gmail.
You can try binding a click event to the tag that will then resize the element to a larger size, but I'm guessing that the flash video player will hijack the click event and not bubble it up to the DOM.
Otherwise, you can have a poster image placeholder, and when that is clicked, you replace the image with the actual video player at whatever size you want.
You could try to let javascript listen to the player's onStateChange event, when state changes to "1" (playing), you change the width and height to the new size. Maybe something like this could work:
var player = document.getElementById("youtube-player");
function onPlayerStateChange(evt) {
if (evt.data == "1") {
player.style.width = "400px";
player.style.height = "300px";
}
}
player.addEventListener("onStateChange", onPlayerStateChange);
You can play around with the javascript api here: https://developers.google.com/youtube/youtube_player_demo And here is the reference: https://developers.google.com/youtube/iframe_api_reference#Events This assumes it's an embed on your on web page, I don't really get what you mean with "... video is recieved in Gmail".