Log in or register to post comments

Video doesn't play in Android device

July 24, 2013 - 7:49pm #1
Hi
 
I'm developing an app in Unity that uses CloudRecognition and video playback. I download videos from a server and store them into the device. The app looks to work fine in IOS but when I build and run the app for Android the app crash after download the video. I tried a lot of things and I decided to start from scratch and modify the original playback example. I found that the app works only when the path variable of VideoPlaybackBehaviour has a valid video path in the editor. Even if I change the path to my video. The problem is that the video plane size and ratio never changes, it  has the dimentions of the original video on the editor. I think that the problem is to initialize the VideoPlaybackBehaviour or VideoPlayerHelper but I can't find where to do that. I also destroyed de video Transform and created again but it didn't work either.
 
What can I do??
thanks

Video doesn't play in Android device

July 29, 2013 - 9:50am #5
I'll change my question since it looks to be the only way to solve my problem.
How can I create the video object and initialize it after that.  what function do I need to execute?
 
Thank you

Video doesn't play in Android device

July 26, 2013 - 4:29pm #4
I tried to change the size with the function InitVideoTexture but it has this comment:
 
// Create texture of size 0 that will be updated in the plugin (we allocate buffers in native code)
 
I think that is the problem. I don't know what can I do to change the videoTexture acording to the video size.

Video doesn't play in Android device

July 26, 2013 - 2:18pm #3
Thank you for your answer
 
The problem is not only the plane size. I know I can modify this size with the last line
 
  transform.localScale = new Vector3(-1 * Mathf.Abs(transform.localScale.x),
                transform.localScale.y, transform.localScale.z);
 
the problem is that since the original video size is 640 x 360 any video I download is cuted to that size. Furthermore when I call the functions
 
mVideoPlayer.GetVideoWidth();
mVideoPlayer.GetVideoHeight();
 
I get this size not the new video size.
 
Maybe if I change this values in the VideoPlayerHelper class but there aren't 
functions SetVideoWidth() and SetVideoHeight().
 
What else can I do?
 
Thank you very much

Video doesn't play in Android device

July 25, 2013 - 11:04pm #2

The source of your issue seems to come from this code in VideoPlaybackBehaviour.cs:

void Start()
    {
        // Find the icon plane (child of this object)
        mIconPlane = transform.Find("Icon").gameObject;
 
        // A filename or url must be set in the inspector
        if (m_path == null || m_path.Length == 0)
        {
            Debug.Log("Please set a video url in the Inspector");
            HandleStateChange(VideoPlayerHelper.MediaState.ERROR);
            mCurrentState = VideoPlayerHelper.MediaState.ERROR;
            this.enabled = false;
        }
        else
        {
            // Set the current state to Not Ready
            HandleStateChange(VideoPlayerHelper.MediaState.NOT_READY);
            mCurrentState = VideoPlayerHelper.MediaState.NOT_READY;
        }
        // Create the video player and set the filename
        mVideoPlayer = new VideoPlayerHelper();
        mVideoPlayer.SetFilename(m_path);
 
        // Flip the plane as the video texture is mirrored on the horizontal
        transform.localScale = new Vector3(-1 * Mathf.Abs(transform.localScale.x),
                transform.localScale.y, transform.localScale.z);
 
        // Scale the icon
        ScaleIcon();
    }

You need to customize the code in such a way to make the video size as you wish

Log in or register to post comments