Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2491] Android: Fullscreen video playback restarts when screen is rotated (orientation changes)

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-07-14T21:05:20.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterJeremy Waite
AssigneeMauro Parra-Miranda
Created2013-08-17T03:25:18.000+0000
Updated2016-03-08T07:41:32.000+0000

Description

When playing a video (mp4) fullscreen using the code below:
var videoPlayer = Titanium.Media.createVideoPlayer({
  url:Alloy.CFG.introVideo, 
  autoplay:true,
  fullscreen:true,
  mediaControlStyle: Titanium.Media.VIDEO_CONTROL_DEFAULT,
  scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
the video starts playing in portrait mode, but when you rotate the device the video playback restarts and the video replayed from the beginning.

Comments

  1. Mostafizur Rahman 2013-09-17

    Hello Jeremy Waite, Is it for Alloy or Titanium? I tested this for Both Alloy and Titanium. I can't reproduce this. Test Environment: Titanium SDK version: 3.1.2 (08/14/13 12:45 5ceaff8) OS: OS X 10.8.4 IOS Simulator Version 6.0 (369.2) Android SDK: 2.3.3 Thanks
  2. Brad Ball 2013-12-04

    I have the same issue on Android, using the code below. Note, tested on ios device running ios 7.0.4 and do NOT have the issue, video continues playing seamlessly when devices is rotated. var Video = Ti.Media.createVideoPlayer({ url: VideoURL, //This is a URL to a streaming mp4 video file (or http live streaming video file on ios) fullscreen: true, autoplay: true, backgroundColor: '#000', mediaControlStyle: Ti.Media.VIDEO_CONTROL_DEFAULT, scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT }); Environment: Application: Titanium (NOT alloy) Titanium SDK Version: 3.1.3 OS: OSX 10.8.5 Android SDK: 4.0 (API 14)
  3. Mostafizur Rahman 2013-12-12

    [~jawaite123@yahoo.com] [~bradleycorn] We tested this issue with the test code below. We were not able to reproduce this issue in Ti SDK 3.1.3.GA. Please test this issue using the latest release and let us know your feedback. H5. Testing Environment: Ti CLI 3.1.2 Titanium SDK: 3.1.3 and later Android Device

    Test Case

       var win = Ti.UI.createWindow();
       
       VideoURL = '/etc/Mat.mp4';
       
       
       var Video = Ti.Media.createVideoPlayer({
       	url : VideoURL, //This is a URL to a streaming mp4 video file (or http live streaming video file on ios)
       	fullscreen : true,
       	autoplay : true,
       	backgroundColor : '#000',
       	mediaControlStyle : Ti.Media.VIDEO_CONTROL_DEFAULT,
       	scalingMode : Ti.Media.VIDEO_SCALING_ASPECT_FIT
       });
       
       win.add(Video);
       
       win.open();
       
       

    Steps to Reproduce:

    Create a simple project.

    Update this code in app.js

    Run this with testing environment

    Rotate android device randomly

    Video will be play continues without any restart

    Thanks
  4. Brad Ball 2013-12-13

    I have some additional feedback on this issue. I created an empty test project following the instructions above and put the following in the app.js:
       var win = Ti.UI.createWindow();
        
       VideoURL = '/etc/Mat.mp4';
        
        
       var Video = Ti.Media.createVideoPlayer({
           url : VideoURL, //This is a URL to a streaming mp4 video file (or http live streaming video file on ios)
           fullscreen : true,
           autoplay : true,
           backgroundColor : '#000',
           mediaControlStyle : Ti.Media.VIDEO_CONTROL_DEFAULT,
           scalingMode : Ti.Media.VIDEO_SCALING_ASPECT_FIT
       });
        
       win.add(Video);
        
       win.open();
       
    the video plays back perfectly on my devices. When I rotate the device, the video continues to play seamlessly. I then updated the node in the tiapp.xml to the following:
           <android xmlns:android="http://schemas.android.com/apk/res/android">
               <tool-api-level>14</tool-api-level>
               <manifest>
                   <uses-sdk android:maxSdkVersion="17" android:minSdkVersion="8" android:targetSdkVersion="14"/>
               </manifest>
           </android>
       
    Now when I run the app on my devices, the error appears. Rotating the device causes the video to restart from the beginning.
  5. Ritu Agrawal 2013-12-25

    This issue can be reproduced with Android SDK version 2.2 (API level 8). But the minimum Android version supported by Titanium SDK is 2.3.3 (API level 10) and the provided test case works fine with Android SDK 2.3.3. Resolving this ticket invalid as API level 8 is unsupported. Please refer to the compatibility matrix in the documentation for more information: http://docs.appcelerator.com/titanium/latest/#!/guide/Titanium_Compatibility_Matrix
  6. Brad Ball 2013-12-31

    I am still seeing this issue, despite udpating the API level in the android manifest. Using the same code as my previous comment above, but changing the android manifest to only support a minimum api level of 11, the bug is still there, the video restarts when rotated. Here is my new manifest entry:
           <android xmlns:android="http://schemas.android.com/apk/res/android">
               <tool-api-level>18</tool-api-level>
               <manifest>
                   <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18"/>
               </manifest>
           </android>
       
  7. Ronnie Swietek 2014-03-07

    I had this problem a long time ago when I was developing for android natively. Try this solution in your tiapp.xml rather than android manifest: http://stackoverflow.com/questions/5983583/rotating-phone-restarts-video-on-android

JSON Source