- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有这段代码:
import UIKit
import MediaPlayer
class ViewController: UIViewController {
var moviePlayer:MPMoviePlayerController!
var bounds: CGRect = UIScreen.mainScreen().bounds
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var width:CGFloat = bounds.size.width
var height = (width / 16) * 9
var url:NSURL = NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v")
moviePlayer = MPMoviePlayerController(contentURL: url)
moviePlayer.view.frame = CGRect(x: 0, y: 40, width: width, height: height)
self.view.addSubview(moviePlayer.view)
moviePlayer.fullscreen = true
moviePlayer.controlStyle = MPMovieControlStyle.Embedded
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
它可以从服务器播放视频,但我在这里有一个问题:
如果我想要纵向模式应用程序,我是否仍然可以在用户以全屏模式播放视频时将其转为横向模式?如果可以,该怎么做?
先谢谢了。
最佳答案
是的。当 MPMoviePlayercontroller 进入全屏模式时,您可以强制更改方向。只需将通知 MPMoviePlayerWillEnterFullscreenNotification 观察者添加到您的 viewdidload/viewwillappear 中,然后如下更改方向
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "videoMPMoviePlayerWillEnterFullscreen:", name: MPMoviePlayerWillEnterFullscreenNotification, object: nil);
//change orientation to portrait when user exits the full screen
NSNotificationCenter.defaultCenter().addObserver(self, selector: "videoMPMoviePlayerWillExitFullscreenNotification:", name: MPMoviePlayerWillExitFullscreenNotification, object: nil);
}
func videoMPMoviePlayerWillEnterFullscreen(notification:NSNotification)
{
let value = UIInterfaceOrientation.LandscapeLeft.rawValue ;// UIInterfaceOrientation.LandscapeRight.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
func videoMPMoviePlayerWillExitFullscreenNotification(notification:NSNotification)
{
let value = UIInterfaceOrientation.Portrait.rawValue ;// UIInterfaceOrientation.LandscapeRight.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
不要忘记移除观察者。
应用程序委托(delegate)可以实现 application:supportedInterfaceOrientationsForWindow: 以返回一个 UIInterfaceOrientationMask,用于代替应用程序的 Info.plist 中的值。
class AppDelegate: UIResponder, UIApplicationDelegate {
.....
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.AllButUpsideDown;//UIInterfaceOrientationMask.All for iPad devices
}
}
引用:- https://developer.apple.com/library/ios/qa/qa1688/_index.html
关于ios - swift : Play Video in Landscape Mode When Fullscreen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26056257/
我正在动态更改背景颜色,我也需要在全屏模式下发生同样的事情。不幸的是,伪类样式不能直接从 javascript 修改。 有什么方法可以说 :fullscreen 类应该遵循与 :not(:fullsc
如何相对于全屏 img 在 和 上放置一个 div?即使调整窗口大小时,我也希望 div 相对于图像位于同一位置。 编辑: 现在几乎可以正常工作了。我将我的 div 定位到外部 div 而不是图像。问
在我的应用程序(C++14、MacOsX 10.11)中,我使用 glfw3 创建两个窗口,它们应该在两个具有不同原始分辨率的显示器中以全屏模式运行。我正在创建这样的窗口: glfwCreateWi
我正在使用 XCode 4.5 版。对于每个 Xib,我可以选择大小为“Retina 3.5 全屏”或“Retina 4 全屏”。 我的疑问是:如果我选择 Retina 4 全屏,我的应用程序能否在旧
我有一个包含两个阶段的应用程序,应分别以全屏模式显示在两个不同的屏幕上。我设法将两个舞台放置在单独的屏幕上,并尝试在每个舞台上将全屏属性设置为true,但只显示了其中的两个而没有进行修饰。总是最后一个
在我的VPS中,我运行了远程桌面并连接到另一个VPS。 现在,新遥控器具有整个屏幕,我无法控制主VPS! 如何切换此全屏模式? 最佳答案 CTRL + ALT + BREAK 在全屏模式和窗口模式之间
我有一个 AVPlayer 与 AVAsset 一起使用来播放视频。 我添加了一些控件,例如播放、停止、前进等... 但是我怎样才能通过按钮切换到全屏呢?我不想使用 MPMoviePlayerCont
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我正在尝试找到最好的方法来创建一个水平网站,全屏,如果可能的话响应式,最小宽度适用于平板电脑。问题是我还需要使用鼠标滚轮进行水平滚动,并且我发现 fullPage.js 不支持这一点,或者至少我无法让
我尝试用 Vitamio 玩直播。我解决了一些问题,但我无法解决这个问题。视频无法全屏播放。这些是我的代码。我希望你能帮帮我!谢谢你,抱歉我的英语不好。 package com.uusoftware.
我使用 setEnabledSystemUIOverlays 来隐藏状态栏和虚拟按钮栏。 但是屏幕顶部和底部有空白(如图所示): 有人知道怎么解决吗? 这是我的代码: import 'package:
我正在尝试向我的程序添加全屏功能,但我无法让它工作。我想 Display.setFullscreen(true); 我尝试将其位置更改为创建显示的位置或设置显示模式的位置上方,但仍然无法正常工作。有什
鉴于 the sheer number 这不存在,我有点惊讶Unicode 中的箭头状符号。我错过了什么吗?或者是否有一个看起来类似于全屏图标的角色? 最佳答案 还有 U+26F6 "SQUARE F
我有一个带有两个按钮的登录 Activity ,一个是我的,另一个来自 Facebook SDK。我可以看到 ID 为“auth”的按钮的宽度和高度等于 facebook 按钮。如果在我设置的 lis
我正在尝试构建一个显示图像的全屏“模态”。我通过创建一个具有最大高度和宽度的 div 来制作模态,给它一个大的 z-index 和固定位置。 在该模式中,我放置了一张图片。我正在尝试使用此 css 自
Capacitor 在文档教程中有关于屏幕方向的信息 (https://capacitorjs.com/docs/v2/guides/screen-orientation#screen-orienta
我试图创建一些 POC 来尝试使用 jwplayer,但由于某种原因,jwplayer 的全屏无法正常工作。 有没有办法在jwplayer的jsfiddle中进行全屏工作? Here is my js
我正在使用 VueJS 开发 PWA。我开始在真实设备中测试我的应用程序(添加到主屏幕)。我的应用程序旨在 100% 高度,因为它显示了一个 map ,如您所见: 有时,从视口(viewport)高度
我使用 i3 窗口管理器并拥有 set $Locker i3lock --color=000000 && sleep 1 exec --no-startup-id xautolock -time 5
我正在使用带有播放列表的 VLC 媒体播放器,其中包含 IP 电视地址。使用我的声卡 Remote ,我可以切换电视 channel 。有时,在更改 channel 时,VLC 会退出全屏模式并返回全
我是一名优秀的程序员,十分优秀!