[TIMOB-26033] iOS: Ti.Media.VideoPlayer shows an error on Window Close on SDK 7.1.1.GA
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2018-05-22T09:36:59.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 7.3.0 |
| Components | iOS |
| Labels | n/a |
| Reporter | Mostafizur Rahman |
| Assignee | Vijay Singh |
| Created | 2018-05-11T15:45:10.000+0000 |
| Updated | 2018-06-21T18:05:22.000+0000 |
Description
Hello,
The following error occurs when closing a window with a video player control with SDK 7.1.1.GA on iOS. On Android, it works just fine.
*Test Environment:*
Appcelerator Command-Line Interface, version 7.0.3
SDK: 7.1.1.GA
*Test code:*
index.xml
<Alloy>
<Window class="container">
<Label id="label" onClick="doClick">Open Video Error Page</Label>
</Window>
</Alloy>
video.xml
<Alloy>
<Window id="winVideo" backgroundColor="#cccccc">
<Label id="videoLocalClose"></Label>
<Label id="videoAdd" top="100" color="blue">Add Video First</Label>
<Label id="videoPlay" top="200" color="purple">Then Play Video</Label>
<Label id="videoWindowClose" bottom="0" height="80" color="red">Close Window With Error</Label>
</Window>
</Alloy>
index.js
function doClick(e) {
Alloy.createController('video', {}).getView().open();
}
$.index.open();
video.js
var activeMovie = null;
var videoMedia = null;
$.videoAdd.addEventListener('click', function(e)
{
Ti.Media.showCamera({
mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO],
videoMaximumDuration: 300000,
videoQuality: Titanium.Media.QUALITY_MEDIUM,
saveToPhotoGallery: true,
allowEditing: false,
success:function(e){
saveVideoLocal(e.media);
}
});
});
function saveVideoLocal(media) {
videoMedia = media;
}
$.videoPlay.addEventListener('click', function(e)
{
activeMovie = Titanium.Media.createVideoPlayer({
top : 0,
width : '100%',
bottom:100,
visible:true,
zIndex:999999,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL,
autoplay : true,
media: videoMedia
});
// Now if I use url instead of media then the video will not play. ( Same of android and iOS)
// If I put a fake url like (url: 'http://fakeMovie.com' and still set media property the video will not play but error will not be thrown)
// You can even put both media and url key above to same videoMedia and it will throw the error.
// Looks like you have to set the url key at the creation of the control to not throw the error.
// But url does not seem to be working for local media where the media key should be used.
// Also when I get the script error the app will not crash but it will also not recognize
//any future clicks on the listview control on the page that opened the video page.
$.winVideo.add(activeMovie);
});
$.videoWindowClose.addEventListener('click', function(e)
{
$.winVideo.close();
});
$.winVideo.addEventListener('close', function(e)
{
if (activeMovie != null) {
activeMovie.release();
$.winVideo.remove(activeMovie);
}
activeMovie = null;
$.destroy();
$.off();
$.winVideo = null;
});
index.tss
".container": {
backgroundColor:"white"
}
"Label": {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#000"
}
"#label": {
font: {
fontSize: 12
}
}
alloy.js
Attach in the text file
Note: Also I have added the full project on the attachment file.
*Error:*
[ERROR] : Script Error {
[ERROR] : column = 24;
[ERROR] : line = 119;
[ERROR] : message = "Cannot remove an observer <TiMediaVideoPlayerProxy 0x11808d000> for the key path \"url\" from <TiMediaVideoPlayerProxy 0x11808d000> because it is not registered as an observer.";
[ERROR] : }
In this test code customer used *media* in the create command to play a video stored on the local device. If they put a fake url in the create it won't throw the error but even though they set the media later then it will not play the video. Again, this only happens on iOS.
Thanks
Attachments
| File | Date | Size |
|---|---|---|
| alloy.js | 2018-05-14T16:35:59.000+0000 | 1696 |
| hypertest.zip | 2018-05-14T17:08:32.000+0000 | 9209344 |
This issue is invalid. The VideoPlayer does not support the
mediaproperty and passinge.mediafrom the video-picker dialog is also not allowed, since it's a Ti.Blob instance, not an actual URL. Please pass thenativePathof the media to theurlproperty and see if that works. Also, the Alloy-based app is hard to debug, so a minimalistic app.js test-case (no styling and external layout config) would help cracking it down in case the above still does not work. *EDIT*: It seems like themediaproperty indeed is supported, although not supported. I would still like to know if passing the native-path of the Blob resolves it already and request the app.js test case (from support).PR - https://github.com/appcelerator/titanium_mobile/pull/10071 Test Case 1 (with url) -
Test Case 2 -var win = Ti.UI.createWindow({ title : 'Starting Window', backgroundColor: 'white' }); var openLabel = Ti.UI.createLabel({ text : "Open Video Window", }); openLabel.addEventListener('click', function(e) { videoWin.open(); }); var videoWin = Ti.UI.createWindow({ title : 'Video window', backgroundColor : '#a5a5a5' }); var activeMovie = null; var playLabel = Ti.UI.createLabel({ text : "Play the video file", top : 200, }); playLabel.addEventListener('click', function(e) { activeMovie = Titanium.Media.createVideoPlayer({ top : 100, width : Ti.UI.FILL, bottom : 200, visible : true, zIndex : 999999, mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT, scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL, autoplay : true, elevation : 24, url : 'https://www.w3schools.com/html/mov_bbb.mp4' }); videoWin.add(activeMovie); }); videoWin.add(playLabel); var closeLabel = Ti.UI.createLabel({ text : "Close Video Window", bottom : 100, }); closeLabel.addEventListener('click', function(e) { if (activeMovie != null) { activeMovie.release(); win.remove(activeMovie); } activeMovie = null; videoWin.close(); }); videoWin.add(closeLabel); win.add(openLabel); win.open();var win = Ti.UI.createWindow({ title : 'Starting Window', backgroundColor: 'white' }); var videoWindow = Ti.UI.createLabel({ top : 300, text : 'open video window' }); videoWindow.addEventListener('click', function(e) { var videoWin = Ti.UI.createWindow({ title : 'Video window', backgroundColor : '#a5a5a5' }); var videoFile = Titanium.Filesystem.getFile(Titanium.Filesystem.getApplicationDataDirectory(), 'Local_Ad_Video_File_1.MOV'); var saveLabel = Ti.UI.createLabel({ text : "Save a video file", top : 200, }); saveLabel.addEventListener('click', function(e) { Ti.Media.showCamera({ mediaTypes : [Ti.Media.MEDIA_TYPE_VIDEO], videoMaximumDuration : 300000, videoQuality : Titanium.Media.QUALITY_MEDIUM, saveToPhotoGallery : true, allowEditing : false, success : function(e) { saveVideoLocal(e.media); } }); saveLabel.hide(); playLabel.show(); }); function saveVideoLocal(media) { videoFile.write(media); } videoWin.add(saveLabel); var activeMovie = null; var playLabel = Ti.UI.createLabel({ text : "Play the video file", top : 200, visible : false }); playLabel.addEventListener('click', function(e) { activeMovie = Titanium.Media.createVideoPlayer({ top : 100, width : Ti.UI.FILL, bottom : 200, visible : true, zIndex : 999999, mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT, scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL, autoplay : true, elevation : 24, url : videoFile.nativePath }); videoWin.add(activeMovie); closeLabel.show(); }); videoWin.add(playLabel); var closeLabel = Ti.UI.createLabel({ text : "Close Video Window", bottom : 100, visible : false }); closeLabel.addEventListener('click', function(e) { if (activeMovie != null) { // THIS IS THE LINE THAT THROWS THE ERROR. Now in the docs it says: //Releases the internal video resources immediately. // This is not usually necessary but can help if you no longer need to use the player after it is used to help converse memory. // It also says android 0.9 and iOS 0.9 but it is throwing the following error on iOS: /* [ERROR] Script Error { [ERROR] column = 23; [ERROR] line = 97; [ERROR] message = "Cannot remove an observer <TiMediaVideoPlayerProxy 0x104016800> for the key path \"url\" from <TiMediaVideoPlayerProxy 0x104016800> because it is not registered as an observer."; [ERROR] } */ // On iOS: if I comment out the release line below it will not throw the error but documentation says it can help conserve memory if used. activeMovie.release(); win.remove(activeMovie); } activeMovie = null; videoWin.close(); }); videoWin.add(closeLabel); videoWin.open(); }); win.add(videoWindow); win.open();*Closing ticket.* fix can be seen in SDK Version:
7.3.0.v20180618182516*FR (Passed) Test Steps:*Created an application with the first test case
Ran the application
Open the video window
Let the video play
Closed the video window
*Application no longer showed an error*
Created a new application with the second test case
Ran the program
Pressed the
Open video windowbuttonPressed the
Save a video filebutton then pressedPlay a video filebuttonClosed the video window
*Application no longer showed an error*
*Test Environment*