Bug? B4i v2.0, VideoView and iOS 9 beta 3

Pendrush

Well-Known Member
Licensed User
Run this code

B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private VideoV As VideoView
    Private btnStop As Button
    Private btnPlay As Button
   
End Sub

Private Sub Application_Start (Nav As NavigationController)
   
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    'NavControl.ShowPage(Page1)
   
           
    VideoV.Initialize("VideoV")
    btnStop.Initialize("btnStop", btnStop.STYLE_SYSTEM)
    btnPlay.Initialize("btnPlay", btnPlay.STYLE_SYSTEM)
   
    Page1.RootPanel.AddView(btnStop, 0, 0, 100, 50)
    Page1.RootPanel.AddView(btnPlay, 0, 0, 100, 50)
    Page1.RootPanel.AddView(VideoV.View, 0, 0, 100%x, 100%y)
   
    btnPlay.Text = "Play"
    btnStop.Text = "Stop"
    btnPlay.Color = Colors.LightGray
    btnStop.Color = Colors.LightGray
   
    VideoV.ShowControls = False
               
    NavControl.ShowPage(Page1)
   
    CallSubDelayed(Me, "PlayVideo")
   
   
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   
    VideoV.View.Height = Height
    VideoV.View.Width = Width
   
    btnPlay.Top = Height - btnPlay.Height
    btnStop.Top = Height - btnStop.Height
    btnStop.Left = Width - btnStop.Width
   
    btnPlay.BringToFront
    btnStop.BringToFront
       
End Sub

Private Sub Application_Background
   
End Sub

Public Sub PlayVideo
   
    VideoV.Stop
    VideoV.LoadVideoUrl("https://devimages.apple.com.edgekey.net/iphone/samples/bipbop/bipbopall.m3u8")
   
End Sub


Private Sub VideoV_Ready
   
    VideoV.Play
   
End Sub


Private Sub btnPlay_Click
   
    PlayVideo
   
End Sub

Private Sub btnStop_Click

    VideoV.Stop
   
End Sub
wait few second for video to start, wait few more seconds, click on Stop, then click on Play and after 10-15 seconds app crash with this log

B4X:
Application_Start
Application_Active
Error occurred on line: 84 (Main)
An AVPlayerItem cannot be associated with more than one instance of AVPlayer
Stack Trace: (
  CoreFoundation       <redacted> + 150
  libobjc.A.dylib      objc_exception_throw + 38
  AVFoundation         <redacted> + 382
  AVFoundation         <redacted> + 266
  MediaPlayer          <redacted> + 50
  MediaPlayer          <redacted> + 1368
  MediaPlayer          <redacted> + 1272
  MediaPlayer          <redacted> + 24
  libdispatch.dylib    <redacted> + 10
  libdispatch.dylib    <redacted> + 22
libdispatch.dylib    _dispatch_main_queue_callback_4CF + 1516
CoreFoundation       <redacted> + 8
CoreFoundation       <redacted> + 1590
CoreFoundation       CFRunLoopRunSpecific + 516
CoreFoundation       CFRunLoopRunInMode + 108
GraphicsServices     GSEventRunModal + 160
UIKit                UIApplicationMain + 144
B4i Example          main + 108
libdyld.dylib        <redacted> + 2
)
This work fine on iOS 8.3 also on 8.4 in Simulator.

Only work around is to initialize VideoView again (as new VideoView) and run video in that new VideoView.
 

Pendrush

Well-Known Member
Licensed User
I'm unable to find any submitted bug of this or similar (MPMoviePlayer) error on Apple's official beta forum.
I hope it's just on bug in this beta version or I need to change 5-6 apps for my customers :(
 
Top