Git Product home page Git Product logo

Comments (10)

mubeenfahmed avatar mubeenfahmed commented on July 26, 2024 1

I'll test it and let you know

from unitynativegallery.

yasirkula avatar yasirkula commented on July 26, 2024

I'm guessing that you are trying to play the video on a RawImage using a VideoPlayer component. In that case, try setting the url of the video player like this:

// This assumes that RawImage is already assigned to the VideoPlayer (either from the Inspector or by code)
videoPlayer.url = videoPath;
//videoPlayer.url = "file://" + videoPath; // try this if it doesn't work with just videoPath
videoPlayer.source = VideoSource.Url;
videoPlayer.Play();

Otherwise, if you are trying to play the video using the NativeGallery.LoadImageAtPath function, it won't work because it supports images only.

P.S. You can check if something is indeed wrong by first trying to play the video via Handheld.PlayFullScreenMovie( "file://" + videoPath );. If this works, then it should be an issue with VideoPlayer.

from unitynativegallery.

mubeenfahmed avatar mubeenfahmed commented on July 26, 2024

Thanks for quick reply,
I tried handheld.PlayFullScreenMovie, but I want to do something similar to the way you displayed images on cube, I want to display videos on cube.

from unitynativegallery.

yasirkula avatar yasirkula commented on July 26, 2024

Try this one:

NativeGallery.GetVideoFromGallery( ( path ) =>
{
	Debug.Log( "Video path: " + path );
	if( path != null )
	{
		// Play the video on a cube
		GameObject cube = GameObject.CreatePrimitive( PrimitiveType.Cube );
		cube.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 5f;
		cube.transform.forward = -Camera.main.transform.forward;
		
		Material material = cube.GetComponent<Renderer>().material;
		if( !material.shader.isSupported ) // happens when Standard shader is not included in the build
			material.shader = Shader.Find( "Legacy Shaders/Diffuse" );

		AudioSource audioSouce = cube.AddComponent<AudioSource>();
		VideoPlayer videoPlayer = cube.AddComponent<VideoPlayer>();
		videoPlayer.renderMode = VideoRenderMode.MaterialOverride;
		videoPlayer.targetMaterialRenderer = cube.GetComponent<Renderer>();
		videoPlayer.targetMaterialProperty = "_MainTex";
		videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
		videoPlayer.EnableAudioTrack( 0, true );
		videoPlayer.SetTargetAudioSource( 0, audioSouce );
		
		videoPlayer.url = path;
		videoPlayer.source = VideoSource.Url;
		videoPlayer.Play();
		audioSouce.Play();
	}
}, "Select a video" );

from unitynativegallery.

mubeenfahmed avatar mubeenfahmed commented on July 26, 2024

Thanks its working now. Just want to ask, After selecting the video it shows me this window:

img_0275

which I don't need. is it possible to remove the above window. So that as soon as I select the video it is displayed on the cube.

from unitynativegallery.

yasirkula avatar yasirkula commented on July 26, 2024

It doesn't seem possible, at least prior to iOS 11:

https://stackoverflow.com/a/5893066/2373034
https://stackoverflow.com/a/48643954/2373034

from unitynativegallery.

mubeenfahmed avatar mubeenfahmed commented on July 26, 2024

https://stackoverflow.com/questions/20190485/how-to-avoid-compression-after-selecting-video-from-uiimagepickercontroller-in-i

It says:

With iOS 11 you can set the property videoExportPreset to AVAssetExportPresetPassthrough to get the original:

if #available(iOS 11.0, *) {
picker.videoExportPreset = AVAssetExportPresetPassthrough
}
The "Video compression..." label just flashes for a few milliseconds and then the export is done.

@diego Renau almost had the correct answer

from unitynativegallery.

yasirkula avatar yasirkula commented on July 26, 2024

To skip the video processing on iOS 11 and later, you can add the following code to line 307 of NativeGallery.mm:

if (@available(iOS 11.0, *)) {
	imagePicker.videoExportPreset = AVAssetExportPresetPassthrough;
}

But it won't work on earlier iOS versions (there will still be a video preview/processing step). I haven't tested it myself.

from unitynativegallery.

mubeenfahmed avatar mubeenfahmed commented on July 26, 2024

I am developing a ar app, therefore I do not want the user to see this "Choose screen", the code I shared with u speed up the compression process but its of no use to me. I will look out for ways if I found one I will let you know, If u figured out a way Kindly update the asset.
Thank you, It is a great asset and u are a great guy. It was nice talking with you.

from unitynativegallery.

yasirkula avatar yasirkula commented on July 26, 2024

It's nice talking with you, too. I'm closing this issue now but feel free to reopen it if you find something new.

from unitynativegallery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.