LivePlayerContext.requestFullScreen

解释:进入全屏

方法参数

Object object

object参数说明 :

示例

扫码体验

请使用百度APP扫码

图片示例

代码示例1 正常竖向

在开发者工具中预览效果 -

  1. <view class="live-play"> <live-player id="myLive" src="{{src}}"></live-player> <div class="section"> <button type="primary" bind:tap="requestFullScreen">进入全屏</button> </div></view>

-

  1. Page({
  2. data: {
  3. cur: 0,
  4. autoplay: false,
  5. src: 'https://vd3.bdstatic.com/mda-ia8e6q3g23py8qdh/hd/mda-ia8e6q3g23py8qdh.mp4?playlist=%5B%22hd%22%5D&auth_key=1521549485-0-0-d5d042ba3555b2d23909d16a82916ebc&bcevod_channel=searchbox_feed&pd=share'
  6. },
  7. onShow(){
  8. console.log('目前此组件在真机双端不能播放,请在开发者工具中查看完整效果');
  9. },
  10. onReady(e) {
  11. const livePlayerContext = swan.createLivePlayerContext('myLive');
  12. this.livePlayerContext = livePlayerContext;
  13. this.livePlayerContext.play();
  14. },
  15. requestFullScreen(e) {
  16. this.livePlayerContext.requestFullScreen({direction: 0});
  17. }
  18. });

代码示例2 屏幕逆时针90度

在开发者工具中预览效果 -

  1. <view class="live-play">
  2. <live-player id="myLive" src="{{src}}"></live-player>
  3. <div class="section">
  4. <button type="primary" bind:tap="requestFullScreen">进入全屏</button>
  5. </div>
  6. </view>

-

  1. Page({
  2. data: {
  3. cur: 0,
  4. autoplay: false,
  5. src: 'https://vd3.bdstatic.com/mda-ia8e6q3g23py8qdh/hd/mda-ia8e6q3g23py8qdh.mp4?playlist=%5B%22hd%22%5D&auth_key=1521549485-0-0-d5d042ba3555b2d23909d16a82916ebc&bcevod_channel=searchbox_feed&pd=share'
  6. },
  7. onShow(){
  8. console.log('目前此组件在真机双端不能播放,请在开发者工具中查看完整效果');
  9. },
  10. onReady(e) {
  11. const livePlayerContext = swan.createLivePlayerContext('myLive');
  12. this.livePlayerContext = livePlayerContext;
  13. this.livePlayerContext.play();
  14. },
  15. requestFullScreen(e) {
  16. this.livePlayerContext.requestFullScreen({direction: 90});
  17. }
  18. });

代码示例3 屏幕顺时针90度

在开发者工具中预览效果 -

  1. Page({
  2. data: {
  3. cur: 0,
  4. autoplay: false,
  5. src: 'https://vd3.bdstatic.com/mda-ia8e6q3g23py8qdh/hd/mda-ia8e6q3g23py8qdh.mp4?playlist=%5B%22hd%22%5D&auth_key=1521549485-0-0-d5d042ba3555b2d23909d16a82916ebc&bcevod_channel=searchbox_feed&pd=share'
  6. },
  7. onShow(){
  8. console.log('目前此组件在真机双端不能播放,请在开发者工具中查看完整效果');
  9. },
  10. onReady(e) {
  11. const livePlayerContext = swan.createLivePlayerContext('myLive');
  12. this.livePlayerContext = livePlayerContext;
  13. this.livePlayerContext.play();
  14. },
  15. requestFullScreen(e) {
  16. this.livePlayerContext.requestFullScreen({direction: -90});
  17. }
  18. });